提交 134e1144 编写于 作者: L Lukáš Doktor

tree: Increase readability of TreeEnvironment

The TreeEnvironment uses default-dict representation, which uses
__repr__ on items. This is not really human friendly and more
importantly it contains dynamic data (object id) which changes per
execution and we are using environment in fingerprint, which does not
really work well for TreeNodeDebug. This patch replaces the __repr__
with __str__ which improves the readability and avoids the dynamic data.
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 3262c280
......@@ -78,8 +78,17 @@ class TreeEnvironment(dict):
return cpy
def __str__(self):
return ",".join((super(TreeEnvironment, self).__str__(),
str(self.origin), str(self.filter_only),
# Use __str__ instead of __repr__ to improve readability
if self:
_values = ["%s: %s" % _ for _ in self.iteritems()]
values = "{%s}" % ", ".join(_values)
_origin = ["%s: %s" % (key, node.path)
for key, node in self.origin.iteritems()]
origin = "{%s}" % ", ".join(_origin)
else:
values = "{}"
origin = "{}"
return ",".join((values, origin, str(self.filter_only),
str(self.filter_out)))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册