Update app.py
Browse files
app.py
CHANGED
@@ -27,6 +27,7 @@ for species, imgpath in species_to_imgpath.items():
|
|
27 |
class Node():
|
28 |
def __init__(self, name):
|
29 |
self.name = name
|
|
|
30 |
self.children = []
|
31 |
|
32 |
def add_child(child):
|
@@ -43,15 +44,24 @@ for species, imgpath in species_to_imgpath.items():
|
|
43 |
child_names = [filename.split('.')[0].split('-')[0] for filename in os.listdir(folderpath)]
|
44 |
|
45 |
if node_name in name_to_node:
|
46 |
-
node = name_to_node
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
# To be finished
|
48 |
-
|
49 |
-
# if filename.endswith('png') or filename.endswith('jpg'):
|
50 |
-
# filepath = os.path.join(folderpath, filename)
|
51 |
-
# imgname_to_filepath[filename] = filepath
|
52 |
-
# nodename = filename.split('.')[0].split('-')[0]
|
53 |
-
# protoID = filename.split('.')[0].split('-')[1]
|
54 |
-
# nodename_to_protoIDs[nodename].append(protoID)
|
55 |
|
56 |
|
57 |
|
|
|
27 |
class Node():
|
28 |
def __init__(self, name):
|
29 |
self.name = name
|
30 |
+
self.parent = None
|
31 |
self.children = []
|
32 |
|
33 |
def add_child(child):
|
|
|
44 |
child_names = [filename.split('.')[0].split('-')[0] for filename in os.listdir(folderpath)]
|
45 |
|
46 |
if node_name in name_to_node:
|
47 |
+
node = name_to_node[node_name]
|
48 |
+
else:
|
49 |
+
node = Node(node_name)
|
50 |
+
|
51 |
+
child_nodes = []
|
52 |
+
for child_name in child_names:
|
53 |
+
if child_name in name_to_node:
|
54 |
+
child_node = name_to_node[child_name]
|
55 |
+
else:
|
56 |
+
child_node = Node(child_name)
|
57 |
+
name_to_node[child_name] = child_node
|
58 |
+
child_node.parent = node
|
59 |
+
child_nodes.append(child_node)
|
60 |
+
|
61 |
+
node.children = child_nodes
|
62 |
+
|
63 |
# To be finished
|
64 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
|
67 |
|