Compare commits
5 Commits
c16788d90b
...
41113119cc
Author | SHA1 | Date |
---|---|---|
Amber | 41113119cc | |
Amber | 02b1d3916f | |
Amber | 8e174308a3 | |
Amber | 179b2ab3f9 | |
Amber | a92c6e8327 |
|
@ -0,0 +1 @@
|
|||
**/__pycache__
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -11,6 +11,8 @@ cmd_parser.add_argument("path")
|
|||
cmd_parser.add_argument("pattern")
|
||||
# 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
|
||||
cmd_parser.add_argument("-e", "--exclude", action="append")
|
||||
|
||||
# start the command line parsing
|
||||
cmd_args = cmd_parser.parse_args()
|
||||
|
|
|
@ -114,7 +114,7 @@ class NerdTree():
|
|||
d.setdefault('not_readable', 1)
|
||||
|
||||
for item in items:
|
||||
if item in _tree_repr.ITEMS_TO_EXCLUDE:
|
||||
if item in self.opts.get('items_to_exclude') or []:
|
||||
continue
|
||||
|
||||
abs_path_item = startpath+item
|
||||
|
@ -205,8 +205,8 @@ class NerdTree():
|
|||
items = rootnode.get('children') or []
|
||||
|
||||
for n, item in enumerate(items):
|
||||
if item['name'] in _tree_repr.ITEMS_TO_EXCLUDE:
|
||||
continue
|
||||
# if item['name'] in _tree_repr.ITEMS_TO_EXCLUDE:
|
||||
# continue
|
||||
|
||||
islast = (n==len(items) -1)
|
||||
|
||||
|
|
|
@ -11,7 +11,8 @@ CHILD_CONNECTOR = '├── '
|
|||
LAST_CHILD_CONNECTOR = '└── '
|
||||
### is the length of child connector and last_child_connector
|
||||
LEVEL_INDENT = 4
|
||||
ITEMS_TO_EXCLUDE = ['__pycache__']
|
||||
# ITEMS_TO_EXCLUDE = ['__pycache__']
|
||||
ITEMS_TO_EXCLUDE = []
|
||||
|
||||
KB = 1024
|
||||
MB = 1024*1024
|
||||
|
@ -51,19 +52,19 @@ def produce_treeline(prec_seps, lsep):
|
|||
return tree_line.rstrip()
|
||||
|
||||
def format(num, unit=None):
|
||||
# if num/GB >=1:
|
||||
# unit = 'GB'
|
||||
# human_number = round(num/GB, 2)
|
||||
# elif num/MB >=1:
|
||||
# unit = 'MB'
|
||||
# human_number = round(num/MB, 2)
|
||||
# elif num/KB >=1:
|
||||
# unit = 'kB'
|
||||
# human_number = round(num/KB, 2)
|
||||
# else:
|
||||
if num/GB >=1 or unit == 'G':
|
||||
unit = 'G'
|
||||
human_number = round(num/GB, 2)
|
||||
elif num/MB >=1 or unit == 'M':
|
||||
unit = 'M'
|
||||
human_number = round(num/MB, 2)
|
||||
elif num/KB >=1 or unit == 'K':
|
||||
unit = 'K'
|
||||
human_number = round(num/KB, 2)
|
||||
else:
|
||||
unit = 'B'
|
||||
human_number = num
|
||||
# unit = 'b'
|
||||
# human_number = num
|
||||
unit = 'b'
|
||||
human_number = num
|
||||
|
||||
return human_number, unit
|
||||
|
|
8
vfind.py
8
vfind.py
|
@ -10,9 +10,15 @@ if __name__ == '__main__':
|
|||
pattern = cmd_args.pattern
|
||||
show_children_nodes = cmd_args.show_children_nodes
|
||||
|
||||
# opts for generatign the tree
|
||||
opts = {
|
||||
'items_to_exclude' : cmd_args.exclude or [],
|
||||
}
|
||||
|
||||
# opts for find
|
||||
find_opts = {
|
||||
'dont_show_children_nodes': not show_children_nodes
|
||||
}
|
||||
|
||||
ntree = NerdTreeFind(path)
|
||||
ntree = NerdTreeFind(path, opts=opts)
|
||||
ntree.find(pattern, opts=find_opts)
|
||||
|
|
Loading…
Reference in New Issue