Skip to content

Commit

Permalink
Merge pull request brunorubin#1 from djcrabhat/feature/allow_duplicat…
Browse files Browse the repository at this point in the history
…e_node_names

set a node id to refer to, to allow for different nodes with the same…
  • Loading branch information
brunorubin authored May 29, 2019
2 parents 3596478 + 553d205 commit b64f6ee
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ssm_tree/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ def get_tree_from_path(path=None):
node_list = []
for index, node in enumerate(path):
if node:
node_list.append({'node': node})
node_id = "/".join(path[0:index + 1])
node_list.append({'node': node, 'id': node_id})
for index, node in enumerate(path):
if index == 1:
node_list[index-1]['parent'] = None
else:
node_list[index-1]['parent'] = node_list[index-2]['node']
node_list[index-1]['parent'] = node_list[index-2]['id']
return node_list

def build_tree(path, recursive, show_encrypted=False):
Expand All @@ -70,7 +71,7 @@ def build_tree(path, recursive, show_encrypted=False):
for item in parameters:
for node in get_tree_from_path(item):
try:
tree.create_node(node['node'],node['node'],parent=node['parent'])
tree.create_node(node['node'],node['id'],parent=node['parent'])
except:
pass
if not tree:
Expand Down

0 comments on commit b64f6ee

Please sign in to comment.