This repository has been archived by the owner on Jan 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
/
gb_utils.py
65 lines (52 loc) · 1.64 KB
/
gb_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import json
import utils
from os.path import split
"""
this is a script for supporting glowing bear UI
"""
def load_tree_node_file(file_path, node_name=None):
if node_name is None:
p, fn = split(file_path)
node_name = fn
folder_node = create_folder_node('\\', node_name)
for l in utils.read_text_file(file_path):
leaf = create_leaf_node(folder_node['path'], l.split('\t')[0])
folder_node['children'].append(leaf)
return folder_node
def create_leaf_node(p_path, name):
n = {
"name": name,
"path": p_path + name + '\\',
"type": "UNKNOWN",
"visualAttributes": [
"LEAF",
"ACTIVE"
],
"conceptPath": p_path + name + '\\'
}
return n
def create_folder_node(p_path, name):
n = {
"name": name,
"path": p_path + name + '\\',
"type": "UNKNOWN",
"visualAttributes": [
"FOLDER",
"ACTIVE"
],
"conceptPath": p_path + name + '\\',
"dimension": "concept",
"children": []
}
return n
def create_tree_nodes():
tree = {"tree_nodes": []}
tree['tree_nodes'].append(load_tree_node_file('./resources/transmart/vital_signs.tsv', 'vital signs'))
tree['tree_nodes'].append(load_tree_node_file('./resources/transmart/typed_documents.tsv', 'typed documents'))
tree['tree_nodes'].append(load_tree_node_file('./resources/transmart/medical_profile.tsv', 'medical profiles'))
tree['tree_nodes'].append(create_leaf_node('\\', 'Anywhere'))
return tree
def main():
print json.dumps(create_tree_nodes())
if __name__ == "__main__":
main()