vfind, elapsed time
This commit is contained in:
parent
8e51984b01
commit
faf18a3965
|
@ -1,3 +1,5 @@
|
|||
import time
|
||||
|
||||
import re
|
||||
|
||||
from src.colors import RED, YELLOW, GREEN, CYAN , BLUE, PURPLE
|
||||
|
@ -14,6 +16,8 @@ class NerdTreeFind(NerdTree):
|
|||
self.item_name = ''
|
||||
self.re_item_name = None
|
||||
self.results = []
|
||||
self.start_time = time.time()
|
||||
self.end_time = None
|
||||
## computed tree for find
|
||||
self.json_tree_find = {}
|
||||
self.find_opts = find_opts
|
||||
|
@ -141,20 +145,31 @@ class NerdTreeFind(NerdTree):
|
|||
raise Exception('Can\'t compile regexp %s, exit' % (new_item_name,))
|
||||
self.json_tree_find = {}
|
||||
|
||||
def print_elapsed_time(self):
|
||||
self.end_time = time.time()
|
||||
self.elapsed_time = round(self.end_time - self.start_time,2)
|
||||
print('\n\nElapsed Time: %s' % CYAN(self.elapsed_time))
|
||||
|
||||
def print(self, item_name='', opts={}):
|
||||
if not item_name and not self.item_name:
|
||||
print('Please use a valid search string')
|
||||
return
|
||||
|
||||
|
||||
if item_name != self.item_name or self.find_opts != opts:
|
||||
self.reset(item_name, opts)
|
||||
self.json_tree_find = self.find_tree_struct()
|
||||
|
||||
if not self.json_tree_find:
|
||||
print('No results')
|
||||
self.print_elapsed_time()
|
||||
return
|
||||
|
||||
print(self.tree_from_struct(self.json_tree_find))
|
||||
tree_res = self.tree_from_struct(self.json_tree_find)
|
||||
print(tree_res)
|
||||
|
||||
self.print_elapsed_time()
|
||||
|
||||
|
||||
def find(self, item_name, opts={}):
|
||||
'''
|
||||
|
|
Loading…
Reference in New Issue