autopep8 -i

This commit is contained in:
Costa Shulyupin 2020-07-20 21:31:20 +03:00
parent 484db0dedc
commit 8af8935cb1
1 changed files with 49 additions and 43 deletions

View File

@ -79,6 +79,7 @@ verbose = False
files = collections.defaultdict(list) files = collections.defaultdict(list)
def print_limited(a, out=None): def print_limited(a, out=None):
out = out if out else sys.stdout out = out if out else sys.stdout
out.write(str(a) + '\n') out.write(str(a) + '\n')
@ -170,7 +171,7 @@ def func_referrers_git_grep(name):
r = extract_referrer(line) r = extract_referrer(line)
# r is list of file line func # r is list of file line func
if verbose and r: if verbose and r:
print("%-40s\t%s"%(("%s:%s"%(r[0],r[1])),r[2])) print("%-40s\t%s" % (("%s:%s" % (r[0], r[1])), r[2]))
return res return res
@ -190,7 +191,8 @@ def func_referrers_cscope(name):
log(l) log(l)
m = re.match(r'([^ ]*) ([^ ]*) ([^ ]*) (.*)', l) m = re.match(r'([^ ]*) ([^ ]*) ([^ ]*) (.*)', l)
file, func, line_num, line_str = m.groups() file, func, line_num, line_str = m.groups()
if func in ignores: continue if func in ignores:
continue
res.append([file, line_num, func]) res.append([file, line_num, func])
if not res and len(name) > 3: if not res and len(name) > 3:
log(name) log(name)
@ -234,12 +236,13 @@ def referrers_tree(name, referrer=None, printed=None, level=0):
name = a[2] name = a[2]
referrers_tree(name, referrer, printed, level + 1) referrers_tree(name, referrer, printed, level + 1)
def referrers(name): def referrers(name):
''' '''
Arg: <identifier> Arg: <identifier>
Ex: nfs_root_data Ex: nfs_root_data
''' '''
#for a in func_referrers_git_grep(name): # for a in func_referrers_git_grep(name):
# print("%s:%s: %s"%(a[0],a[1],a[2])) # print("%s:%s: %s"%(a[0],a[1],a[2]))
print(' '.join([a[2] for a in func_referrers_git_grep(name)])) print(' '.join([a[2] for a in func_referrers_git_grep(name)]))
@ -488,6 +491,7 @@ def most_used(dg, ins=10, outs=10):
def starts(dg): # roots def starts(dg): # roots
return {n: dg.out_degree(n) for (n, d) in dg.in_degree if not d} return {n: dg.out_degree(n) for (n, d) in dg.in_degree if not d}
def exclude(i, excludes=[], ignores=ignores): def exclude(i, excludes=[], ignores=ignores):
if i in ignores: if i in ignores:
return True return True
@ -495,7 +499,8 @@ def exclude(i, excludes=[], ignores=ignores):
if re.match(e, i): if re.match(e, i):
return True return True
def digraph_predecessors(dg, starts, levels = 100, excludes = [], ignores=ignores):
def digraph_predecessors(dg, starts, levels=100, excludes=[], ignores=ignores):
dg = to_dg(dg) dg = to_dg(dg)
passed = set() passed = set()
# for i in [_ for _ in dg.predecessors(start)]: # for i in [_ for _ in dg.predecessors(start)]:
@ -503,8 +508,8 @@ def digraph_predecessors(dg, starts, levels = 100, excludes = [], ignores=ignore
for e in excludes: for e in excludes:
log(e) log(e)
while levels: while levels:
#log(levels) # log(levels)
#log(starts) # log(starts)
s2 = starts s2 = starts
starts = set() starts = set()
for s in s2: for s in s2:
@ -514,7 +519,7 @@ def digraph_predecessors(dg, starts, levels = 100, excludes = [], ignores=ignore
passed.add(i) passed.add(i)
starts.add(i) starts.add(i)
p.add_edge(i, s) p.add_edge(i, s)
levels-=1 levels -= 1
return p return p
@ -575,7 +580,7 @@ def digraph_print(dg, starts=None, dst_fn=None, sort=False):
if outs: if outs:
s += ' ...' if level > level_limit - 2 else '' s += ' ...' if level > level_limit - 2 else ''
else: else:
s+=' @' + path s += ' @' + path
print_limited(level*'\t' + str(node) + s, dst) print_limited(level*'\t' + str(node) + s, dst)
printed.add(node) printed.add(node)
if level > level_limit - 2: if level > level_limit - 2:
@ -1131,7 +1136,7 @@ def doxygen(*input):
''' '''
log(' '.join([i for i in input])) log(' '.join([i for i in input]))
p = run(['doxygen', '-'], stdout=PIPE, p = run(['doxygen', '-'], stdout=PIPE,
input = "INPUT=" + ' '.join([i for i in input]) + """ input="INPUT=" + ' '.join([i for i in input]) + """
EXCLUDE_SYMBOLS=*310* *311* SOC_ENUM_SINGLE* EXPORT_SYMBOL* EXCLUDE_SYMBOLS=*310* *311* SOC_ENUM_SINGLE* EXPORT_SYMBOL*
CALL_GRAPH = YES CALL_GRAPH = YES
EXTRACT_ALL = YES EXTRACT_ALL = YES
@ -1168,7 +1173,8 @@ def doxygen_xml(a):
d = xml.dom.minidom.parse(x) d = xml.dom.minidom.parse(x)
for m in d.getElementsByTagName("memberdef"): for m in d.getElementsByTagName("memberdef"):
n = m.getElementsByTagName("name")[0].firstChild.data n = m.getElementsByTagName("name")[0].firstChild.data
file = m.getElementsByTagName("location")[0].getAttribute('file') file = (m.getElementsByTagName("location")[0]
.getAttribute('file'))
if file not in files: if file not in files:
print(file) print(file)
if n == 'main': if n == 'main':