提交 63c8137d 编写于 作者: L Lukáš Doktor 提交者: Amador Pahim

avocado: Avoid getting `TreeNode.multiplex` attribute directly

The `multiplex` argument is soon to be removed from the default
variables of the `tree.TreeNode`. Let's adjust the code, where we keep
the knowledge about the multiplexing to get the option or return None
when not present. The ultimate goal is obviously removing all those
places, but let's keep them optional until we have all the API available
to remove those direct low-level usages.
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 4cceb60c
......@@ -52,7 +52,7 @@ class MuxTree(object):
""" yield leaves or muxes of the tree """
queue = collections.deque()
while node is not None:
if node.is_leaf or node.multiplex:
if node.is_leaf or getattr(node, "multiplex", None):
yield node
else:
queue.extendleft(reversed(node.children))
......
......@@ -510,7 +510,7 @@ def tree_view(root, verbose=None, use_utf8=None):
Generate this node's tree-view
:return: list of lines
"""
if node.multiplex:
if getattr(node, "multiplex", None):
down = charset['DoubleDown']
down_right = charset['DoubleDownRight']
right = charset['DoubleRight']
......@@ -563,7 +563,7 @@ def tree_view(root, verbose=None, use_utf8=None):
'DoubleDownRight': ' #== ',
'DoubleRight': ' #== ',
'Value': ' -> '}
if root.multiplex:
if getattr(root, "multiplex", None):
down = charset['DoubleDown']
down_right = charset['DoubleDownRight']
right = charset['DoubleRight']
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册