forked from Imagelibrary/littlefs
scripts: Dropped cycle detection from table renderer
Now that cycle detection is always done at result collection time, we don't need this in the table renderer itself. This had a tendency to cause problems for non-function scripts (ctx.py, structs.py).
This commit is contained in:
@@ -667,7 +667,6 @@ def table(Result, results, diff_results=None, *,
|
||||
summary=False,
|
||||
depth=1,
|
||||
hot=None,
|
||||
detect_cycles=True,
|
||||
**_):
|
||||
all_, all = all, __builtins__.all
|
||||
|
||||
@@ -689,15 +688,11 @@ def table(Result, results, diff_results=None, *,
|
||||
class HotResult(Result_):
|
||||
_i = '_hot_i'
|
||||
_children = '_hot_children'
|
||||
_notes = '_hot_notes'
|
||||
|
||||
def __new__(cls, r, i=None, children=None, notes=None):
|
||||
self = HotResult._make(r)
|
||||
self._hot_i = i
|
||||
self._hot_children = children if children is not None else []
|
||||
self._hot_notes = notes if notes is not None else set()
|
||||
if hasattr(Result_, '_notes'):
|
||||
self._hot_notes.update(getattr(r, r._notes))
|
||||
return self
|
||||
|
||||
def __add__(self, other):
|
||||
@@ -706,13 +701,12 @@ def table(Result, results, diff_results=None, *,
|
||||
self._hot_i if other._hot_i is None
|
||||
else other._hot_i if self._hot_i is None
|
||||
else min(self._hot_i, other._hot_i),
|
||||
self._hot_children + other._hot_children,
|
||||
self._hot_notes | other._hot_notes)
|
||||
self._hot_children + other._hot_children)
|
||||
|
||||
results_ = []
|
||||
for r in results:
|
||||
hot_ = []
|
||||
def recurse(results_, depth_, seen=set()):
|
||||
def recurse(results_, depth_):
|
||||
nonlocal hot_
|
||||
if not results_:
|
||||
return
|
||||
@@ -731,17 +725,10 @@ def table(Result, results, diff_results=None, *,
|
||||
for k in it.chain(hot, [None])))
|
||||
hot_.append(HotResult(r, i=len(hot_)))
|
||||
|
||||
# found a cycle?
|
||||
if (detect_cycles
|
||||
and tuple(getattr(r, k) for k in Result._by) in seen):
|
||||
hot_[-1]._hot_notes.add('cycle detected')
|
||||
return
|
||||
|
||||
# recurse?
|
||||
if depth_ > 1:
|
||||
recurse(getattr(r, Result._children),
|
||||
depth_-1,
|
||||
seen | {tuple(getattr(r, k) for k in Result._by)})
|
||||
depth_-1)
|
||||
|
||||
recurse(getattr(r, Result._children), depth-1)
|
||||
results_.append(HotResult(r, children=hot_))
|
||||
@@ -899,7 +886,7 @@ def table(Result, results, diff_results=None, *,
|
||||
return entry
|
||||
|
||||
# recursive entry helper, only used by some scripts
|
||||
def recurse(results_, depth_, seen=set(),
|
||||
def recurse(results_, depth_,
|
||||
prefixes=('', '', '', '')):
|
||||
# build the children table at each layer
|
||||
results_ = fold(Result, results_, by=by)
|
||||
@@ -934,20 +921,12 @@ def table(Result, results, diff_results=None, *,
|
||||
line = [x if isinstance(x, tuple) else (x, []) for x in line]
|
||||
# add prefixes
|
||||
line[0] = (prefixes[0+is_last] + line[0][0], line[0][1])
|
||||
# add cycle detection
|
||||
if detect_cycles and name in seen:
|
||||
line[-1] = (line[-1][0], line[-1][1] + ['cycle detected'])
|
||||
lines.append(line)
|
||||
|
||||
# found a cycle?
|
||||
if detect_cycles and name in seen:
|
||||
continue
|
||||
|
||||
# recurse?
|
||||
if depth_ > 1:
|
||||
recurse(getattr(r, Result._children),
|
||||
depth_-1,
|
||||
seen | {name},
|
||||
(prefixes[2+is_last] + "|-> ",
|
||||
prefixes[2+is_last] + "'-> ",
|
||||
prefixes[2+is_last] + "| ",
|
||||
@@ -967,7 +946,6 @@ def table(Result, results, diff_results=None, *,
|
||||
if name in table and depth > 1:
|
||||
recurse(getattr(table[name], Result._children),
|
||||
depth-1,
|
||||
{name},
|
||||
("|-> ",
|
||||
"'-> ",
|
||||
"| ",
|
||||
|
||||
@@ -401,7 +401,6 @@ def table(Result, results, diff_results=None, *,
|
||||
summary=False,
|
||||
depth=1,
|
||||
hot=None,
|
||||
detect_cycles=True,
|
||||
**_):
|
||||
all_, all = all, __builtins__.all
|
||||
|
||||
@@ -423,15 +422,11 @@ def table(Result, results, diff_results=None, *,
|
||||
class HotResult(Result_):
|
||||
_i = '_hot_i'
|
||||
_children = '_hot_children'
|
||||
_notes = '_hot_notes'
|
||||
|
||||
def __new__(cls, r, i=None, children=None, notes=None):
|
||||
self = HotResult._make(r)
|
||||
self._hot_i = i
|
||||
self._hot_children = children if children is not None else []
|
||||
self._hot_notes = notes if notes is not None else set()
|
||||
if hasattr(Result_, '_notes'):
|
||||
self._hot_notes.update(getattr(r, r._notes))
|
||||
return self
|
||||
|
||||
def __add__(self, other):
|
||||
@@ -440,13 +435,12 @@ def table(Result, results, diff_results=None, *,
|
||||
self._hot_i if other._hot_i is None
|
||||
else other._hot_i if self._hot_i is None
|
||||
else min(self._hot_i, other._hot_i),
|
||||
self._hot_children + other._hot_children,
|
||||
self._hot_notes | other._hot_notes)
|
||||
self._hot_children + other._hot_children)
|
||||
|
||||
results_ = []
|
||||
for r in results:
|
||||
hot_ = []
|
||||
def recurse(results_, depth_, seen=set()):
|
||||
def recurse(results_, depth_):
|
||||
nonlocal hot_
|
||||
if not results_:
|
||||
return
|
||||
@@ -465,17 +459,10 @@ def table(Result, results, diff_results=None, *,
|
||||
for k in it.chain(hot, [None])))
|
||||
hot_.append(HotResult(r, i=len(hot_)))
|
||||
|
||||
# found a cycle?
|
||||
if (detect_cycles
|
||||
and tuple(getattr(r, k) for k in Result._by) in seen):
|
||||
hot_[-1]._hot_notes.add('cycle detected')
|
||||
return
|
||||
|
||||
# recurse?
|
||||
if depth_ > 1:
|
||||
recurse(getattr(r, Result._children),
|
||||
depth_-1,
|
||||
seen | {tuple(getattr(r, k) for k in Result._by)})
|
||||
depth_-1)
|
||||
|
||||
recurse(getattr(r, Result._children), depth-1)
|
||||
results_.append(HotResult(r, children=hot_))
|
||||
@@ -633,7 +620,7 @@ def table(Result, results, diff_results=None, *,
|
||||
return entry
|
||||
|
||||
# recursive entry helper, only used by some scripts
|
||||
def recurse(results_, depth_, seen=set(),
|
||||
def recurse(results_, depth_,
|
||||
prefixes=('', '', '', '')):
|
||||
# build the children table at each layer
|
||||
results_ = fold(Result, results_, by=by)
|
||||
@@ -668,20 +655,12 @@ def table(Result, results, diff_results=None, *,
|
||||
line = [x if isinstance(x, tuple) else (x, []) for x in line]
|
||||
# add prefixes
|
||||
line[0] = (prefixes[0+is_last] + line[0][0], line[0][1])
|
||||
# add cycle detection
|
||||
if detect_cycles and name in seen:
|
||||
line[-1] = (line[-1][0], line[-1][1] + ['cycle detected'])
|
||||
lines.append(line)
|
||||
|
||||
# found a cycle?
|
||||
if detect_cycles and name in seen:
|
||||
continue
|
||||
|
||||
# recurse?
|
||||
if depth_ > 1:
|
||||
recurse(getattr(r, Result._children),
|
||||
depth_-1,
|
||||
seen | {name},
|
||||
(prefixes[2+is_last] + "|-> ",
|
||||
prefixes[2+is_last] + "'-> ",
|
||||
prefixes[2+is_last] + "| ",
|
||||
@@ -701,7 +680,6 @@ def table(Result, results, diff_results=None, *,
|
||||
if name in table and depth > 1:
|
||||
recurse(getattr(table[name], Result._children),
|
||||
depth-1,
|
||||
{name},
|
||||
("|-> ",
|
||||
"'-> ",
|
||||
"| ",
|
||||
|
||||
@@ -1416,7 +1416,6 @@ def table(Result, results, diff_results=None, *,
|
||||
summary=False,
|
||||
depth=1,
|
||||
hot=None,
|
||||
detect_cycles=True,
|
||||
**_):
|
||||
all_, all = all, __builtins__.all
|
||||
|
||||
@@ -1438,15 +1437,11 @@ def table(Result, results, diff_results=None, *,
|
||||
class HotResult(Result_):
|
||||
_i = '_hot_i'
|
||||
_children = '_hot_children'
|
||||
_notes = '_hot_notes'
|
||||
|
||||
def __new__(cls, r, i=None, children=None, notes=None):
|
||||
self = HotResult._make(r)
|
||||
self._hot_i = i
|
||||
self._hot_children = children if children is not None else []
|
||||
self._hot_notes = notes if notes is not None else set()
|
||||
if hasattr(Result_, '_notes'):
|
||||
self._hot_notes.update(getattr(r, r._notes))
|
||||
return self
|
||||
|
||||
def __add__(self, other):
|
||||
@@ -1455,13 +1450,12 @@ def table(Result, results, diff_results=None, *,
|
||||
self._hot_i if other._hot_i is None
|
||||
else other._hot_i if self._hot_i is None
|
||||
else min(self._hot_i, other._hot_i),
|
||||
self._hot_children + other._hot_children,
|
||||
self._hot_notes | other._hot_notes)
|
||||
self._hot_children + other._hot_children)
|
||||
|
||||
results_ = []
|
||||
for r in results:
|
||||
hot_ = []
|
||||
def recurse(results_, depth_, seen=set()):
|
||||
def recurse(results_, depth_):
|
||||
nonlocal hot_
|
||||
if not results_:
|
||||
return
|
||||
@@ -1480,17 +1474,10 @@ def table(Result, results, diff_results=None, *,
|
||||
for k in it.chain(hot, [None])))
|
||||
hot_.append(HotResult(r, i=len(hot_)))
|
||||
|
||||
# found a cycle?
|
||||
if (detect_cycles
|
||||
and tuple(getattr(r, k) for k in Result._by) in seen):
|
||||
hot_[-1]._hot_notes.add('cycle detected')
|
||||
return
|
||||
|
||||
# recurse?
|
||||
if depth_ > 1:
|
||||
recurse(getattr(r, Result._children),
|
||||
depth_-1,
|
||||
seen | {tuple(getattr(r, k) for k in Result._by)})
|
||||
depth_-1)
|
||||
|
||||
recurse(getattr(r, Result._children), depth-1)
|
||||
results_.append(HotResult(r, children=hot_))
|
||||
@@ -1648,7 +1635,7 @@ def table(Result, results, diff_results=None, *,
|
||||
return entry
|
||||
|
||||
# recursive entry helper, only used by some scripts
|
||||
def recurse(results_, depth_, seen=set(),
|
||||
def recurse(results_, depth_,
|
||||
prefixes=('', '', '', '')):
|
||||
# build the children table at each layer
|
||||
results_ = fold(Result, results_, by=by)
|
||||
@@ -1683,20 +1670,12 @@ def table(Result, results, diff_results=None, *,
|
||||
line = [x if isinstance(x, tuple) else (x, []) for x in line]
|
||||
# add prefixes
|
||||
line[0] = (prefixes[0+is_last] + line[0][0], line[0][1])
|
||||
# add cycle detection
|
||||
if detect_cycles and name in seen:
|
||||
line[-1] = (line[-1][0], line[-1][1] + ['cycle detected'])
|
||||
lines.append(line)
|
||||
|
||||
# found a cycle?
|
||||
if detect_cycles and name in seen:
|
||||
continue
|
||||
|
||||
# recurse?
|
||||
if depth_ > 1:
|
||||
recurse(getattr(r, Result._children),
|
||||
depth_-1,
|
||||
seen | {name},
|
||||
(prefixes[2+is_last] + "|-> ",
|
||||
prefixes[2+is_last] + "'-> ",
|
||||
prefixes[2+is_last] + "| ",
|
||||
@@ -1716,7 +1695,6 @@ def table(Result, results, diff_results=None, *,
|
||||
if name in table and depth > 1:
|
||||
recurse(getattr(table[name], Result._children),
|
||||
depth-1,
|
||||
{name},
|
||||
("|-> ",
|
||||
"'-> ",
|
||||
"| ",
|
||||
|
||||
@@ -875,7 +875,6 @@ def table(Result, results, diff_results=None, *,
|
||||
summary=False,
|
||||
depth=1,
|
||||
hot=None,
|
||||
detect_cycles=True,
|
||||
**_):
|
||||
all_, all = all, __builtins__.all
|
||||
|
||||
@@ -897,15 +896,11 @@ def table(Result, results, diff_results=None, *,
|
||||
class HotResult(Result_):
|
||||
_i = '_hot_i'
|
||||
_children = '_hot_children'
|
||||
_notes = '_hot_notes'
|
||||
|
||||
def __new__(cls, r, i=None, children=None, notes=None):
|
||||
self = HotResult._make(r)
|
||||
self._hot_i = i
|
||||
self._hot_children = children if children is not None else []
|
||||
self._hot_notes = notes if notes is not None else set()
|
||||
if hasattr(Result_, '_notes'):
|
||||
self._hot_notes.update(getattr(r, r._notes))
|
||||
return self
|
||||
|
||||
def __add__(self, other):
|
||||
@@ -914,13 +909,12 @@ def table(Result, results, diff_results=None, *,
|
||||
self._hot_i if other._hot_i is None
|
||||
else other._hot_i if self._hot_i is None
|
||||
else min(self._hot_i, other._hot_i),
|
||||
self._hot_children + other._hot_children,
|
||||
self._hot_notes | other._hot_notes)
|
||||
self._hot_children + other._hot_children)
|
||||
|
||||
results_ = []
|
||||
for r in results:
|
||||
hot_ = []
|
||||
def recurse(results_, depth_, seen=set()):
|
||||
def recurse(results_, depth_):
|
||||
nonlocal hot_
|
||||
if not results_:
|
||||
return
|
||||
@@ -939,17 +933,10 @@ def table(Result, results, diff_results=None, *,
|
||||
for k in it.chain(hot, [None])))
|
||||
hot_.append(HotResult(r, i=len(hot_)))
|
||||
|
||||
# found a cycle?
|
||||
if (detect_cycles
|
||||
and tuple(getattr(r, k) for k in Result._by) in seen):
|
||||
hot_[-1]._hot_notes.add('cycle detected')
|
||||
return
|
||||
|
||||
# recurse?
|
||||
if depth_ > 1:
|
||||
recurse(getattr(r, Result._children),
|
||||
depth_-1,
|
||||
seen | {tuple(getattr(r, k) for k in Result._by)})
|
||||
depth_-1)
|
||||
|
||||
recurse(getattr(r, Result._children), depth-1)
|
||||
results_.append(HotResult(r, children=hot_))
|
||||
@@ -1107,7 +1094,7 @@ def table(Result, results, diff_results=None, *,
|
||||
return entry
|
||||
|
||||
# recursive entry helper, only used by some scripts
|
||||
def recurse(results_, depth_, seen=set(),
|
||||
def recurse(results_, depth_,
|
||||
prefixes=('', '', '', '')):
|
||||
# build the children table at each layer
|
||||
results_ = fold(Result, results_, by=by)
|
||||
@@ -1142,20 +1129,12 @@ def table(Result, results, diff_results=None, *,
|
||||
line = [x if isinstance(x, tuple) else (x, []) for x in line]
|
||||
# add prefixes
|
||||
line[0] = (prefixes[0+is_last] + line[0][0], line[0][1])
|
||||
# add cycle detection
|
||||
if detect_cycles and name in seen:
|
||||
line[-1] = (line[-1][0], line[-1][1] + ['cycle detected'])
|
||||
lines.append(line)
|
||||
|
||||
# found a cycle?
|
||||
if detect_cycles and name in seen:
|
||||
continue
|
||||
|
||||
# recurse?
|
||||
if depth_ > 1:
|
||||
recurse(getattr(r, Result._children),
|
||||
depth_-1,
|
||||
seen | {name},
|
||||
(prefixes[2+is_last] + "|-> ",
|
||||
prefixes[2+is_last] + "'-> ",
|
||||
prefixes[2+is_last] + "| ",
|
||||
@@ -1175,7 +1154,6 @@ def table(Result, results, diff_results=None, *,
|
||||
if name in table and depth > 1:
|
||||
recurse(getattr(table[name], Result._children),
|
||||
depth-1,
|
||||
{name},
|
||||
("|-> ",
|
||||
"'-> ",
|
||||
"| ",
|
||||
@@ -1326,7 +1304,6 @@ def main(obj_paths, *,
|
||||
by=by if by is not None else ['function'],
|
||||
fields=fields,
|
||||
sort=sort,
|
||||
detect_cycles=False,
|
||||
**args)
|
||||
|
||||
|
||||
|
||||
@@ -667,7 +667,6 @@ def table(Result, results, diff_results=None, *,
|
||||
summary=False,
|
||||
depth=1,
|
||||
hot=None,
|
||||
detect_cycles=True,
|
||||
**_):
|
||||
all_, all = all, __builtins__.all
|
||||
|
||||
@@ -689,15 +688,11 @@ def table(Result, results, diff_results=None, *,
|
||||
class HotResult(Result_):
|
||||
_i = '_hot_i'
|
||||
_children = '_hot_children'
|
||||
_notes = '_hot_notes'
|
||||
|
||||
def __new__(cls, r, i=None, children=None, notes=None):
|
||||
self = HotResult._make(r)
|
||||
self._hot_i = i
|
||||
self._hot_children = children if children is not None else []
|
||||
self._hot_notes = notes if notes is not None else set()
|
||||
if hasattr(Result_, '_notes'):
|
||||
self._hot_notes.update(getattr(r, r._notes))
|
||||
return self
|
||||
|
||||
def __add__(self, other):
|
||||
@@ -706,13 +701,12 @@ def table(Result, results, diff_results=None, *,
|
||||
self._hot_i if other._hot_i is None
|
||||
else other._hot_i if self._hot_i is None
|
||||
else min(self._hot_i, other._hot_i),
|
||||
self._hot_children + other._hot_children,
|
||||
self._hot_notes | other._hot_notes)
|
||||
self._hot_children + other._hot_children)
|
||||
|
||||
results_ = []
|
||||
for r in results:
|
||||
hot_ = []
|
||||
def recurse(results_, depth_, seen=set()):
|
||||
def recurse(results_, depth_):
|
||||
nonlocal hot_
|
||||
if not results_:
|
||||
return
|
||||
@@ -731,17 +725,10 @@ def table(Result, results, diff_results=None, *,
|
||||
for k in it.chain(hot, [None])))
|
||||
hot_.append(HotResult(r, i=len(hot_)))
|
||||
|
||||
# found a cycle?
|
||||
if (detect_cycles
|
||||
and tuple(getattr(r, k) for k in Result._by) in seen):
|
||||
hot_[-1]._hot_notes.add('cycle detected')
|
||||
return
|
||||
|
||||
# recurse?
|
||||
if depth_ > 1:
|
||||
recurse(getattr(r, Result._children),
|
||||
depth_-1,
|
||||
seen | {tuple(getattr(r, k) for k in Result._by)})
|
||||
depth_-1)
|
||||
|
||||
recurse(getattr(r, Result._children), depth-1)
|
||||
results_.append(HotResult(r, children=hot_))
|
||||
@@ -899,7 +886,7 @@ def table(Result, results, diff_results=None, *,
|
||||
return entry
|
||||
|
||||
# recursive entry helper, only used by some scripts
|
||||
def recurse(results_, depth_, seen=set(),
|
||||
def recurse(results_, depth_,
|
||||
prefixes=('', '', '', '')):
|
||||
# build the children table at each layer
|
||||
results_ = fold(Result, results_, by=by)
|
||||
@@ -934,20 +921,12 @@ def table(Result, results, diff_results=None, *,
|
||||
line = [x if isinstance(x, tuple) else (x, []) for x in line]
|
||||
# add prefixes
|
||||
line[0] = (prefixes[0+is_last] + line[0][0], line[0][1])
|
||||
# add cycle detection
|
||||
if detect_cycles and name in seen:
|
||||
line[-1] = (line[-1][0], line[-1][1] + ['cycle detected'])
|
||||
lines.append(line)
|
||||
|
||||
# found a cycle?
|
||||
if detect_cycles and name in seen:
|
||||
continue
|
||||
|
||||
# recurse?
|
||||
if depth_ > 1:
|
||||
recurse(getattr(r, Result._children),
|
||||
depth_-1,
|
||||
seen | {name},
|
||||
(prefixes[2+is_last] + "|-> ",
|
||||
prefixes[2+is_last] + "'-> ",
|
||||
prefixes[2+is_last] + "| ",
|
||||
@@ -967,7 +946,6 @@ def table(Result, results, diff_results=None, *,
|
||||
if name in table and depth > 1:
|
||||
recurse(getattr(table[name], Result._children),
|
||||
depth-1,
|
||||
{name},
|
||||
("|-> ",
|
||||
"'-> ",
|
||||
"| ",
|
||||
|
||||
@@ -847,7 +847,6 @@ def table(Result, results, diff_results=None, *,
|
||||
summary=False,
|
||||
depth=1,
|
||||
hot=None,
|
||||
detect_cycles=True,
|
||||
**_):
|
||||
all_, all = all, __builtins__.all
|
||||
|
||||
@@ -869,15 +868,11 @@ def table(Result, results, diff_results=None, *,
|
||||
class HotResult(Result_):
|
||||
_i = '_hot_i'
|
||||
_children = '_hot_children'
|
||||
_notes = '_hot_notes'
|
||||
|
||||
def __new__(cls, r, i=None, children=None, notes=None):
|
||||
self = HotResult._make(r)
|
||||
self._hot_i = i
|
||||
self._hot_children = children if children is not None else []
|
||||
self._hot_notes = notes if notes is not None else set()
|
||||
if hasattr(Result_, '_notes'):
|
||||
self._hot_notes.update(getattr(r, r._notes))
|
||||
return self
|
||||
|
||||
def __add__(self, other):
|
||||
@@ -886,13 +881,12 @@ def table(Result, results, diff_results=None, *,
|
||||
self._hot_i if other._hot_i is None
|
||||
else other._hot_i if self._hot_i is None
|
||||
else min(self._hot_i, other._hot_i),
|
||||
self._hot_children + other._hot_children,
|
||||
self._hot_notes | other._hot_notes)
|
||||
self._hot_children + other._hot_children)
|
||||
|
||||
results_ = []
|
||||
for r in results:
|
||||
hot_ = []
|
||||
def recurse(results_, depth_, seen=set()):
|
||||
def recurse(results_, depth_):
|
||||
nonlocal hot_
|
||||
if not results_:
|
||||
return
|
||||
@@ -911,17 +905,10 @@ def table(Result, results, diff_results=None, *,
|
||||
for k in it.chain(hot, [None])))
|
||||
hot_.append(HotResult(r, i=len(hot_)))
|
||||
|
||||
# found a cycle?
|
||||
if (detect_cycles
|
||||
and tuple(getattr(r, k) for k in Result._by) in seen):
|
||||
hot_[-1]._hot_notes.add('cycle detected')
|
||||
return
|
||||
|
||||
# recurse?
|
||||
if depth_ > 1:
|
||||
recurse(getattr(r, Result._children),
|
||||
depth_-1,
|
||||
seen | {tuple(getattr(r, k) for k in Result._by)})
|
||||
depth_-1)
|
||||
|
||||
recurse(getattr(r, Result._children), depth-1)
|
||||
results_.append(HotResult(r, children=hot_))
|
||||
@@ -1079,7 +1066,7 @@ def table(Result, results, diff_results=None, *,
|
||||
return entry
|
||||
|
||||
# recursive entry helper, only used by some scripts
|
||||
def recurse(results_, depth_, seen=set(),
|
||||
def recurse(results_, depth_,
|
||||
prefixes=('', '', '', '')):
|
||||
# build the children table at each layer
|
||||
results_ = fold(Result, results_, by=by)
|
||||
@@ -1114,20 +1101,12 @@ def table(Result, results, diff_results=None, *,
|
||||
line = [x if isinstance(x, tuple) else (x, []) for x in line]
|
||||
# add prefixes
|
||||
line[0] = (prefixes[0+is_last] + line[0][0], line[0][1])
|
||||
# add cycle detection
|
||||
if detect_cycles and name in seen:
|
||||
line[-1] = (line[-1][0], line[-1][1] + ['cycle detected'])
|
||||
lines.append(line)
|
||||
|
||||
# found a cycle?
|
||||
if detect_cycles and name in seen:
|
||||
continue
|
||||
|
||||
# recurse?
|
||||
if depth_ > 1:
|
||||
recurse(getattr(r, Result._children),
|
||||
depth_-1,
|
||||
seen | {name},
|
||||
(prefixes[2+is_last] + "|-> ",
|
||||
prefixes[2+is_last] + "'-> ",
|
||||
prefixes[2+is_last] + "| ",
|
||||
@@ -1147,7 +1126,6 @@ def table(Result, results, diff_results=None, *,
|
||||
if name in table and depth > 1:
|
||||
recurse(getattr(table[name], Result._children),
|
||||
depth-1,
|
||||
{name},
|
||||
("|-> ",
|
||||
"'-> ",
|
||||
"| ",
|
||||
|
||||
@@ -817,7 +817,6 @@ def table(Result, results, diff_results=None, *,
|
||||
summary=False,
|
||||
depth=1,
|
||||
hot=None,
|
||||
detect_cycles=True,
|
||||
**_):
|
||||
all_, all = all, __builtins__.all
|
||||
|
||||
@@ -839,15 +838,11 @@ def table(Result, results, diff_results=None, *,
|
||||
class HotResult(Result_):
|
||||
_i = '_hot_i'
|
||||
_children = '_hot_children'
|
||||
_notes = '_hot_notes'
|
||||
|
||||
def __new__(cls, r, i=None, children=None, notes=None):
|
||||
self = HotResult._make(r)
|
||||
self._hot_i = i
|
||||
self._hot_children = children if children is not None else []
|
||||
self._hot_notes = notes if notes is not None else set()
|
||||
if hasattr(Result_, '_notes'):
|
||||
self._hot_notes.update(getattr(r, r._notes))
|
||||
return self
|
||||
|
||||
def __add__(self, other):
|
||||
@@ -856,13 +851,12 @@ def table(Result, results, diff_results=None, *,
|
||||
self._hot_i if other._hot_i is None
|
||||
else other._hot_i if self._hot_i is None
|
||||
else min(self._hot_i, other._hot_i),
|
||||
self._hot_children + other._hot_children,
|
||||
self._hot_notes | other._hot_notes)
|
||||
self._hot_children + other._hot_children)
|
||||
|
||||
results_ = []
|
||||
for r in results:
|
||||
hot_ = []
|
||||
def recurse(results_, depth_, seen=set()):
|
||||
def recurse(results_, depth_):
|
||||
nonlocal hot_
|
||||
if not results_:
|
||||
return
|
||||
@@ -881,17 +875,10 @@ def table(Result, results, diff_results=None, *,
|
||||
for k in it.chain(hot, [None])))
|
||||
hot_.append(HotResult(r, i=len(hot_)))
|
||||
|
||||
# found a cycle?
|
||||
if (detect_cycles
|
||||
and tuple(getattr(r, k) for k in Result._by) in seen):
|
||||
hot_[-1]._hot_notes.add('cycle detected')
|
||||
return
|
||||
|
||||
# recurse?
|
||||
if depth_ > 1:
|
||||
recurse(getattr(r, Result._children),
|
||||
depth_-1,
|
||||
seen | {tuple(getattr(r, k) for k in Result._by)})
|
||||
depth_-1)
|
||||
|
||||
recurse(getattr(r, Result._children), depth-1)
|
||||
results_.append(HotResult(r, children=hot_))
|
||||
@@ -1049,7 +1036,7 @@ def table(Result, results, diff_results=None, *,
|
||||
return entry
|
||||
|
||||
# recursive entry helper, only used by some scripts
|
||||
def recurse(results_, depth_, seen=set(),
|
||||
def recurse(results_, depth_,
|
||||
prefixes=('', '', '', '')):
|
||||
# build the children table at each layer
|
||||
results_ = fold(Result, results_, by=by)
|
||||
@@ -1084,20 +1071,12 @@ def table(Result, results, diff_results=None, *,
|
||||
line = [x if isinstance(x, tuple) else (x, []) for x in line]
|
||||
# add prefixes
|
||||
line[0] = (prefixes[0+is_last] + line[0][0], line[0][1])
|
||||
# add cycle detection
|
||||
if detect_cycles and name in seen:
|
||||
line[-1] = (line[-1][0], line[-1][1] + ['cycle detected'])
|
||||
lines.append(line)
|
||||
|
||||
# found a cycle?
|
||||
if detect_cycles and name in seen:
|
||||
continue
|
||||
|
||||
# recurse?
|
||||
if depth_ > 1:
|
||||
recurse(getattr(r, Result._children),
|
||||
depth_-1,
|
||||
seen | {name},
|
||||
(prefixes[2+is_last] + "|-> ",
|
||||
prefixes[2+is_last] + "'-> ",
|
||||
prefixes[2+is_last] + "| ",
|
||||
@@ -1117,7 +1096,6 @@ def table(Result, results, diff_results=None, *,
|
||||
if name in table and depth > 1:
|
||||
recurse(getattr(table[name], Result._children),
|
||||
depth-1,
|
||||
{name},
|
||||
("|-> ",
|
||||
"'-> ",
|
||||
"| ",
|
||||
|
||||
@@ -906,7 +906,6 @@ def table(Result, results, diff_results=None, *,
|
||||
summary=False,
|
||||
depth=1,
|
||||
hot=None,
|
||||
detect_cycles=True,
|
||||
**_):
|
||||
all_, all = all, __builtins__.all
|
||||
|
||||
@@ -928,15 +927,11 @@ def table(Result, results, diff_results=None, *,
|
||||
class HotResult(Result_):
|
||||
_i = '_hot_i'
|
||||
_children = '_hot_children'
|
||||
_notes = '_hot_notes'
|
||||
|
||||
def __new__(cls, r, i=None, children=None, notes=None):
|
||||
self = HotResult._make(r)
|
||||
self._hot_i = i
|
||||
self._hot_children = children if children is not None else []
|
||||
self._hot_notes = notes if notes is not None else set()
|
||||
if hasattr(Result_, '_notes'):
|
||||
self._hot_notes.update(getattr(r, r._notes))
|
||||
return self
|
||||
|
||||
def __add__(self, other):
|
||||
@@ -945,13 +940,12 @@ def table(Result, results, diff_results=None, *,
|
||||
self._hot_i if other._hot_i is None
|
||||
else other._hot_i if self._hot_i is None
|
||||
else min(self._hot_i, other._hot_i),
|
||||
self._hot_children + other._hot_children,
|
||||
self._hot_notes | other._hot_notes)
|
||||
self._hot_children + other._hot_children)
|
||||
|
||||
results_ = []
|
||||
for r in results:
|
||||
hot_ = []
|
||||
def recurse(results_, depth_, seen=set()):
|
||||
def recurse(results_, depth_):
|
||||
nonlocal hot_
|
||||
if not results_:
|
||||
return
|
||||
@@ -970,17 +964,10 @@ def table(Result, results, diff_results=None, *,
|
||||
for k in it.chain(hot, [None])))
|
||||
hot_.append(HotResult(r, i=len(hot_)))
|
||||
|
||||
# found a cycle?
|
||||
if (detect_cycles
|
||||
and tuple(getattr(r, k) for k in Result._by) in seen):
|
||||
hot_[-1]._hot_notes.add('cycle detected')
|
||||
return
|
||||
|
||||
# recurse?
|
||||
if depth_ > 1:
|
||||
recurse(getattr(r, Result._children),
|
||||
depth_-1,
|
||||
seen | {tuple(getattr(r, k) for k in Result._by)})
|
||||
depth_-1)
|
||||
|
||||
recurse(getattr(r, Result._children), depth-1)
|
||||
results_.append(HotResult(r, children=hot_))
|
||||
@@ -1138,7 +1125,7 @@ def table(Result, results, diff_results=None, *,
|
||||
return entry
|
||||
|
||||
# recursive entry helper, only used by some scripts
|
||||
def recurse(results_, depth_, seen=set(),
|
||||
def recurse(results_, depth_,
|
||||
prefixes=('', '', '', '')):
|
||||
# build the children table at each layer
|
||||
results_ = fold(Result, results_, by=by)
|
||||
@@ -1173,20 +1160,12 @@ def table(Result, results, diff_results=None, *,
|
||||
line = [x if isinstance(x, tuple) else (x, []) for x in line]
|
||||
# add prefixes
|
||||
line[0] = (prefixes[0+is_last] + line[0][0], line[0][1])
|
||||
# add cycle detection
|
||||
if detect_cycles and name in seen:
|
||||
line[-1] = (line[-1][0], line[-1][1] + ['cycle detected'])
|
||||
lines.append(line)
|
||||
|
||||
# found a cycle?
|
||||
if detect_cycles and name in seen:
|
||||
continue
|
||||
|
||||
# recurse?
|
||||
if depth_ > 1:
|
||||
recurse(getattr(r, Result._children),
|
||||
depth_-1,
|
||||
seen | {name},
|
||||
(prefixes[2+is_last] + "|-> ",
|
||||
prefixes[2+is_last] + "'-> ",
|
||||
prefixes[2+is_last] + "| ",
|
||||
@@ -1206,7 +1185,6 @@ def table(Result, results, diff_results=None, *,
|
||||
if name in table and depth > 1:
|
||||
recurse(getattr(table[name], Result._children),
|
||||
depth-1,
|
||||
{name},
|
||||
("|-> ",
|
||||
"'-> ",
|
||||
"| ",
|
||||
@@ -1367,7 +1345,6 @@ def main(paths,
|
||||
by=by if by is not None else ['function'],
|
||||
fields=fields,
|
||||
sort=sort,
|
||||
detect_cycles=False,
|
||||
**args)
|
||||
|
||||
# error on recursion
|
||||
|
||||
@@ -689,7 +689,6 @@ def table(Result, results, diff_results=None, *,
|
||||
summary=False,
|
||||
depth=1,
|
||||
hot=None,
|
||||
detect_cycles=True,
|
||||
**_):
|
||||
all_, all = all, __builtins__.all
|
||||
|
||||
@@ -711,15 +710,11 @@ def table(Result, results, diff_results=None, *,
|
||||
class HotResult(Result_):
|
||||
_i = '_hot_i'
|
||||
_children = '_hot_children'
|
||||
_notes = '_hot_notes'
|
||||
|
||||
def __new__(cls, r, i=None, children=None, notes=None):
|
||||
self = HotResult._make(r)
|
||||
self._hot_i = i
|
||||
self._hot_children = children if children is not None else []
|
||||
self._hot_notes = notes if notes is not None else set()
|
||||
if hasattr(Result_, '_notes'):
|
||||
self._hot_notes.update(getattr(r, r._notes))
|
||||
return self
|
||||
|
||||
def __add__(self, other):
|
||||
@@ -728,13 +723,12 @@ def table(Result, results, diff_results=None, *,
|
||||
self._hot_i if other._hot_i is None
|
||||
else other._hot_i if self._hot_i is None
|
||||
else min(self._hot_i, other._hot_i),
|
||||
self._hot_children + other._hot_children,
|
||||
self._hot_notes | other._hot_notes)
|
||||
self._hot_children + other._hot_children)
|
||||
|
||||
results_ = []
|
||||
for r in results:
|
||||
hot_ = []
|
||||
def recurse(results_, depth_, seen=set()):
|
||||
def recurse(results_, depth_):
|
||||
nonlocal hot_
|
||||
if not results_:
|
||||
return
|
||||
@@ -753,17 +747,10 @@ def table(Result, results, diff_results=None, *,
|
||||
for k in it.chain(hot, [None])))
|
||||
hot_.append(HotResult(r, i=len(hot_)))
|
||||
|
||||
# found a cycle?
|
||||
if (detect_cycles
|
||||
and tuple(getattr(r, k) for k in Result._by) in seen):
|
||||
hot_[-1]._hot_notes.add('cycle detected')
|
||||
return
|
||||
|
||||
# recurse?
|
||||
if depth_ > 1:
|
||||
recurse(getattr(r, Result._children),
|
||||
depth_-1,
|
||||
seen | {tuple(getattr(r, k) for k in Result._by)})
|
||||
depth_-1)
|
||||
|
||||
recurse(getattr(r, Result._children), depth-1)
|
||||
results_.append(HotResult(r, children=hot_))
|
||||
@@ -921,7 +908,7 @@ def table(Result, results, diff_results=None, *,
|
||||
return entry
|
||||
|
||||
# recursive entry helper, only used by some scripts
|
||||
def recurse(results_, depth_, seen=set(),
|
||||
def recurse(results_, depth_,
|
||||
prefixes=('', '', '', '')):
|
||||
# build the children table at each layer
|
||||
results_ = fold(Result, results_, by=by)
|
||||
@@ -956,20 +943,12 @@ def table(Result, results, diff_results=None, *,
|
||||
line = [x if isinstance(x, tuple) else (x, []) for x in line]
|
||||
# add prefixes
|
||||
line[0] = (prefixes[0+is_last] + line[0][0], line[0][1])
|
||||
# add cycle detection
|
||||
if detect_cycles and name in seen:
|
||||
line[-1] = (line[-1][0], line[-1][1] + ['cycle detected'])
|
||||
lines.append(line)
|
||||
|
||||
# found a cycle?
|
||||
if detect_cycles and name in seen:
|
||||
continue
|
||||
|
||||
# recurse?
|
||||
if depth_ > 1:
|
||||
recurse(getattr(r, Result._children),
|
||||
depth_-1,
|
||||
seen | {name},
|
||||
(prefixes[2+is_last] + "|-> ",
|
||||
prefixes[2+is_last] + "'-> ",
|
||||
prefixes[2+is_last] + "| ",
|
||||
@@ -989,7 +968,6 @@ def table(Result, results, diff_results=None, *,
|
||||
if name in table and depth > 1:
|
||||
recurse(getattr(table[name], Result._children),
|
||||
depth-1,
|
||||
{name},
|
||||
("|-> ",
|
||||
"'-> ",
|
||||
"| ",
|
||||
@@ -1140,7 +1118,6 @@ def main(obj_paths, *,
|
||||
by=by if by is not None else ['struct'],
|
||||
fields=fields,
|
||||
sort=sort,
|
||||
detect_cycles=False,
|
||||
**args)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user