This commit is contained in:
Costa Shulyupin 2020-10-07 17:52:00 +03:00
parent f8744448c9
commit 37c0745475
1 changed files with 10 additions and 10 deletions

View File

@ -56,13 +56,14 @@ files = collections.defaultdict(list)
def print_limited(a, out=None): def print_limited(a, out=None):
# exits when reaches limit of printed lines # exits when reaches limit of printed lines
out = out if out else sys.stdout out = out if out else sys.stdout
out.write(str(a) + '\n')
global n global n
n += 1 n += 1
if n > limit + 1: if n > limit + 1:
out.write('...') out.write(str(a) + ' ...\n')
out.write('\t...\n')
sys.exit(1) sys.exit(1)
# raise(Exception('Reached limit')) # raise(Exception('Reached limit'))
out.write(str(a) + '\n')
def log(*args, **kwargs): def log(*args, **kwargs):
@ -207,15 +208,14 @@ def referrers_tree(name, referrer=None, printed=None, level=0):
printed = set() printed = set()
# definition # definition
# cscope -d -L1 "arv_camera_new" # cscope -d -L1 "arv_camera_new"
if level > level_limit - 2:
print_limited(level*'\t' + name + ' ...')
return ''
if name in printed: if name in printed:
print_limited(level*'\t' + name + ' ^') print_limited(level*'\t' + name + ' ^')
return return
else:
print_limited(level*'\t' + name)
printed.add(name) printed.add(name)
if level > level_limit - 2: print_limited(level*'\t' + name)
print_limited((level + 1)*'\t' + '...')
return ''
for a in referrer(name): for a in referrer(name):
name = a[2] name = a[2]
referrers_tree(name, referrer, printed, level + 1) referrers_tree(name, referrer, printed, level + 1)
@ -272,15 +272,15 @@ def call_tree(node, printed=None, level=0):
return False return False
if printed is None: if printed is None:
printed = set() printed = set()
if level > level_limit - 2:
print_limited(level*'\t' + node + ' ...')
return ''
if node in printed: if node in printed:
print_limited(level*'\t' + node + ' ^') print_limited(level*'\t' + node + ' ^')
return return
else: else:
print_limited(level*'\t' + node) print_limited(level*'\t' + node)
printed.add(node) printed.add(node)
if level > level_limit - 2:
print_limited((level + 1)*'\t' + '...')
return ''
local_printed = set() local_printed = set()
for line in popen('cscope -d -L2 "%s"' % (node)): for line in popen('cscope -d -L2 "%s"' % (node)):
a = line.split()[1] a = line.split()[1]