tree find opt: dont_show_children_nodes

This commit is contained in:
Amber 2024-01-23 09:33:24 +01:00
parent eea94fd4aa
commit 6e3ea51aaa
2 changed files with 10 additions and 3 deletions

View File

@ -234,13 +234,20 @@ def find_children(tree, item_abs_path):
return (False, [])
def find_tree_struct(startpath, item_name):
def find_tree_struct(startpath, item_name, opts={}):
'''
'''
results = find_node(startpath, item_name)
dont_show_children_nodes = True if opts.get('dont_show_children_nodes') else False
if not results:
return {}
if dont_show_children_nodes:
for result in results:
result['children'] = []
tree_struct = {}
for node in results:
@ -277,8 +284,8 @@ def nerd_tree(startpath):
tree_txt = nerd_tree_from_struct(tree_struct)
print(tree_txt)
def find_nerd_tree(startpath, item_name):
tree_struct = find_tree_struct(startpath, item_name)
def find_nerd_tree(startpath, item_name, opts={}):
tree_struct = find_tree_struct(startpath, item_name, opts=opts)
if not tree_struct:
print('No results')
return