separate find_options from options

This commit is contained in:
Amber 2024-03-18 14:21:10 +01:00
parent 2f8c7d82c5
commit c272cba222
2 changed files with 15 additions and 12 deletions

View File

@ -3,6 +3,7 @@ from pathlib import Path
from src.colors import RED, YELLOW, GREEN, CYAN , BLUE, PURPLE from src.colors import RED, YELLOW, GREEN, CYAN , BLUE, PURPLE
import src.tree_repr as _tree_repr import src.tree_repr as _tree_repr
import src.tree_find as _tree_find
class NerdTree(): class NerdTree():
''' '''
@ -211,14 +212,15 @@ class NerdTree():
items = rootnode.get('children') or [] items = rootnode.get('children') or []
if isinstance(self, _tree_find.NerdTreeFind):
nodefound = rootnode.get('found') nodefound = rootnode.get('found')
if nodefound: if nodefound:
if self.opts['dont_show_children_nodes'] or self.opts['show_subtree_info']: if self.find_opts['dont_show_children_nodes'] or self.find_opts['show_subtree_info']:
if rootnode.get('subtree_items'): if rootnode.get('subtree_items'):
hnum, unit = _tree_repr.format(rootnode['subtree_size']) hnum, unit = _tree_repr.format(rootnode['subtree_size'])
nerd_tree_txt += ' (%s item(s)/%s%s ▾)' % (rootnode['subtree_items'], hnum, unit) nerd_tree_txt += ' (%s item(s)/%s%s ▾)' % (rootnode['subtree_items'], hnum, unit)
if self.opts['dont_show_children_nodes']: items = [] if self.find_opts['dont_show_children_nodes']: items = []
for n, item in enumerate(items): for n, item in enumerate(items):
# if item['name'] in _tree_repr.ITEMS_TO_EXCLUDE: # if item['name'] in _tree_repr.ITEMS_TO_EXCLUDE:
@ -241,7 +243,8 @@ class NerdTree():
treeline = _tree_repr.produce_treeline(prec_seps, (sep, {'name' : ' '})) + ' ' + self.tree_from_struct(item, prec_seps=seps) treeline = _tree_repr.produce_treeline(prec_seps, (sep, {'name' : ' '})) + ' ' + self.tree_from_struct(item, prec_seps=seps)
else: else:
treeline = _tree_repr.produce_treeline(prec_seps, (sep, item)) treeline = _tree_repr.produce_treeline(prec_seps, (sep, item))
if item.get('found') and self.opts['show_subtree_info']: if isinstance(self, _tree_find.NerdTreeFind):
if item.get('found') and self.find_opts['show_subtree_info']:
hnum, unit = _tree_repr.format(item['size']) hnum, unit = _tree_repr.format(item['size'])
treeline += ' (%s%s)' % (hnum, unit) treeline += ' (%s%s)' % (hnum, unit)

View File

@ -101,8 +101,8 @@ class NerdTreeFind(NerdTree):
dont_show_children_nodes = self.find_opts['dont_show_children_nodes'] if self.find_opts.get('dont_show_children_nodes') is not None else False dont_show_children_nodes = self.find_opts['dont_show_children_nodes'] if self.find_opts.get('dont_show_children_nodes') is not None else False
show_subtree_info = self.find_opts['show_subtree_info'] if self.find_opts.get('show_subtree_info') is not None else False show_subtree_info = self.find_opts['show_subtree_info'] if self.find_opts.get('show_subtree_info') is not None else False
self.opts['dont_show_children_nodes'] = dont_show_children_nodes # self.opts['dont_show_children_nodes'] = dont_show_children_nodes
self.opts['show_subtree_info'] = show_subtree_info # self.opts['show_subtree_info'] = show_subtree_info
tree_struct = {} tree_struct = {}