From f9a1c59b35931fc55cc9d09385c0c127c2e7e1d4 Mon Sep 17 00:00:00 2001 From: Vincenzo Maffione Date: Sat, 18 Mar 2017 19:17:02 +0100 Subject: model: fix __repr__ to correctly handle multiple registration entries --- rumba/model.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/rumba/model.py b/rumba/model.py index 23db86f..19c1182 100644 --- a/rumba/model.py +++ b/rumba/model.py @@ -168,28 +168,32 @@ class Node: def __repr__(self): s = "Node " + self.name + ":\n" - s += " IPCPs in DIFs: [" - for d in self.difs: - s += " %s" % d.name + + s += " DIFs: [ " + s += " ".join([d.name for d in self.difs]) s += " ]\n" + s += " DIF registrations: [ " + rl = [] for dif_a, difs in self.dif_registrations.items(): - s += "%s => [" % dif_a.name - for dif_b in difs: - s += " %s" % dif_b.name - s += " ]" + x = "%s => [" % dif_a.name + x += " ".join([dif_b.name for dif_b in difs]) + x += "]" + rl.append(x) + s += ", ".join(rl) s += " ]\n" + s += " Name registrations: [ " for name, difs in self.registrations.items(): - s += "%s => [" % name - for dif in difs: - s += " %s" % dif.name + s += "%s => [ " % name + s += " ".join([dif.name for dif in difs]) s += " ]" s += " ]\n" + s += " Bindings: [ " - for ap, name in self.bindings.items(): - s += "'%s' => '%s'" % (ap, name) + s += ", ".join(["'%s' => '%s'" % (ap, name) for ap, name in self.bindings.items()]) s += " ]\n" + return s def add_dif(self, dif): -- cgit v1.2.3