Always include last step in names

This commit is contained in:
Sebastien Bourdeauducq 2012-01-19 18:42:43 +01:00
parent 4eac60d181
commit 00d3eb7989
1 changed files with 16 additions and 14 deletions

View File

@ -63,12 +63,11 @@ def _bin(sn, sig_iters):
terminals = [] terminals = []
bins = {} bins = {}
for signal, it in sig_iters: for signal, it in sig_iters:
try: step, last = next(it)
step = it.__next__()
except StopIteration:
terminals.append(signal)
else:
step_name = sn.name(step) step_name = sn.name(step)
if last:
terminals.append((step_name, signal))
else:
if step_name not in bins: if step_name not in bins:
bins[step_name] = [] bins[step_name] = []
bins[step_name].append((signal, it)) bins[step_name].append((signal, it))
@ -86,19 +85,24 @@ def _r_build_pnd(sn, sig_iters):
if intersection: if intersection:
for prefix, sub_pnd in bins_named: for prefix, sub_pnd in bins_named:
for s, n in sub_pnd.items(): for s, n in sub_pnd.items():
if n:
r[s] = prefix + "_" + n r[s] = prefix + "_" + n
else:
r[s] = prefix
else: else:
for prefix, sub_pnd in bins_named: for prefix, sub_pnd in bins_named:
r.update(sub_pnd) r.update(sub_pnd)
for t in terminals: for n, s in terminals:
r[t] = "" r[s] = n
return r return r
def last_flagged(seq):
seq = iter(seq)
a = next(seq)
for b in seq:
yield a, False
a = b
yield a, True
def build_pnd(signals): def build_pnd(signals):
sig_iters = [(signal, iter(signal.backtrace)) sig_iters = [(signal, last_flagged(signal.backtrace))
for signal in signals] for signal in signals]
return _r_build_pnd(_StepNamer(), sig_iters) return _r_build_pnd(_StepNamer(), sig_iters)
@ -113,8 +117,6 @@ class Namespace:
sig_name = sig.name_override sig_name = sig.name_override
else: else:
sig_name = self.pnd[sig] sig_name = self.pnd[sig]
if not sig_name:
sig_name = "anonymous"
try: try:
n = self.sigs[sig] n = self.sigs[sig]
except KeyError: except KeyError: