提交 b8b9fee2 编写于 作者: R Rudá Moura 提交者: Cleber Rosa

avocado.multiplexer: improvements in path_parent and any_sibling.

Include documentation for path_parent and any_sibling and
use variable names more relevant.

In function any_sibling, if the number of arguments is less than 2,
then returns False, because it is obviously alone.
Signed-off-by: NRuda Moura <rmoura@redhat.com>
上级 e453a1f6
......@@ -24,16 +24,30 @@ import collections
from avocado.core import tree
def path_parent(element):
e = element.rpartition('/')[0]
if e == '':
return '/'
return e
def any_sibling(*args):
result = set(arg.parent for arg in args)
return len(args) != len(result)
def path_parent(path):
"""
From a given path, return its parent path.
:param path: the node path as string.
:return: the parent path as string.
"""
parent = path.rpartition('/')[0]
if parent == '':
return '/root'
return parent
def any_sibling(*nodes):
"""
Check if there is any sibling.
:param nodes: the nodes to check.
:return: `True` if there is any sibling or `False`.
"""
if len(nodes) < 2:
return False
parents = set(node.parent for node in nodes)
return len(nodes) != len(parents)
# only allow items which match the filter
# siblings and their children will be removed
......@@ -117,7 +131,6 @@ def multiplex(*args, **kwargs):
# second level of filtering above should use the filter strings
# extracted from the node being worked on
# (not implemented here, so using [] as placeholders)
result = [x + [y] for x in result for y in pool
if any_sibling(*(x + [y])) is False and
filter_only(y.environment.get('filter-only', []), x + [y]) and
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册