From c272cba222b52ce6e1d649542c5244fc98f4b55b Mon Sep 17 00:00:00 2001 From: Amber Date: Mon, 18 Mar 2024 14:21:10 +0100 Subject: [PATCH] separate find_options from options --- src/tree.py | 23 +++++++++++++---------- src/tree_find.py | 4 ++-- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/tree.py b/src/tree.py index 8ff41f9..85f464b 100644 --- a/src/tree.py +++ b/src/tree.py @@ -3,6 +3,7 @@ from pathlib import Path from src.colors import RED, YELLOW, GREEN, CYAN , BLUE, PURPLE import src.tree_repr as _tree_repr +import src.tree_find as _tree_find class NerdTree(): ''' @@ -211,14 +212,15 @@ class NerdTree(): items = rootnode.get('children') or [] - nodefound = rootnode.get('found') - if nodefound: - if self.opts['dont_show_children_nodes'] or self.opts['show_subtree_info']: - if rootnode.get('subtree_items'): - hnum, unit = _tree_repr.format(rootnode['subtree_size']) - nerd_tree_txt += ' (%s item(s)/%s%s ▾)' % (rootnode['subtree_items'], hnum, unit) + if isinstance(self, _tree_find.NerdTreeFind): + nodefound = rootnode.get('found') + if nodefound: + if self.find_opts['dont_show_children_nodes'] or self.find_opts['show_subtree_info']: + if rootnode.get('subtree_items'): + hnum, unit = _tree_repr.format(rootnode['subtree_size']) + 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): # if item['name'] in _tree_repr.ITEMS_TO_EXCLUDE: @@ -241,9 +243,10 @@ class NerdTree(): treeline = _tree_repr.produce_treeline(prec_seps, (sep, {'name' : ' '})) + ' ' + self.tree_from_struct(item, prec_seps=seps) else: treeline = _tree_repr.produce_treeline(prec_seps, (sep, item)) - if item.get('found') and self.opts['show_subtree_info']: - hnum, unit = _tree_repr.format(item['size']) - treeline += ' (%s%s)' % (hnum, unit) + if isinstance(self, _tree_find.NerdTreeFind): + if item.get('found') and self.find_opts['show_subtree_info']: + hnum, unit = _tree_repr.format(item['size']) + treeline += ' (%s%s)' % (hnum, unit) nerd_tree_txt += '\n' + treeline diff --git a/src/tree_find.py b/src/tree_find.py index 8393cd0..d893cf1 100644 --- a/src/tree_find.py +++ b/src/tree_find.py @@ -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 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['show_subtree_info'] = show_subtree_info + # self.opts['dont_show_children_nodes'] = dont_show_children_nodes + # self.opts['show_subtree_info'] = show_subtree_info tree_struct = {}