adding type search
This commit is contained in:
parent
babce420c7
commit
f16897721f
|
@ -9,6 +9,7 @@ cmd_parser = argparse.ArgumentParser(
|
|||
|
||||
cmd_parser.add_argument("path")
|
||||
cmd_parser.add_argument("pattern")
|
||||
cmd_parser.add_argument("-t", "--type")
|
||||
# if -s is found in the command line cmd_args.show_children_nodes is True
|
||||
cmd_parser.add_argument("-s", "--show-children-nodes", action="store_true")
|
||||
## more than one occurrencies of -e option are appended in a list
|
||||
|
|
|
@ -19,9 +19,19 @@ class NerdTreeFind(NerdTree):
|
|||
self.find_opts = find_opts
|
||||
NerdTree.__init__(self, startpath, opts=opts)
|
||||
|
||||
def found_true_cond(self, test_node):
|
||||
search_type = self.find_opts['type'] if self.find_opts.get('type') else None
|
||||
|
||||
if not search_type: test_type = True
|
||||
else: test_type = (test_node['type'] == search_type)
|
||||
|
||||
test_match = True if self.re_item_name.match(test_node['name']) else False
|
||||
return all([test_match, test_type])
|
||||
|
||||
def find_node_recursively(self, node):
|
||||
# if node['name'] == self.item_name:
|
||||
if self.re_item_name.match(node['name']):
|
||||
# if self.re_item_name.match(node['name']):
|
||||
if self.found_true_cond(node):
|
||||
node_copy = node.copy()
|
||||
node_copy.update({'color_formatter' : YELLOW, 'found' : 1})
|
||||
self.results.append(node_copy)
|
||||
|
@ -33,7 +43,8 @@ class NerdTreeFind(NerdTree):
|
|||
self.find_node_recursively(item_child)
|
||||
else:
|
||||
# if item_child['name'] == self.item_name:
|
||||
if self.re_item_name.match(item_child['name']):
|
||||
# if self.re_item_name.match(item_child['name']):
|
||||
if self.found_true_cond(item_child):
|
||||
item_child_copy = item_child.copy()
|
||||
item_child_copy.update({'color_formatter' : YELLOW, 'found' : 1})
|
||||
self.results.append(item_child_copy)
|
||||
|
|
Loading…
Reference in New Issue