コード例 #1
0
def collect_package_restrictions(restrict, attrs=None, invert=False):
    """Collect PackageRestriction instances inside a restriction.

    :param restrict: package instance to scan
    :param attrs: None (return all package restrictions), or a sequence of
        specific attrs the package restriction must work against.
    """
    if not isinstance(restrict, (list, tuple)):
        restrict = [restrict]
    for r in restrict:
        if not isinstance(r, restriction.base):
            raise TypeError('restrict must be of a restriction.base, '
                            f'not {r.__class__.__class__}: {r!r}')
    if attrs is None:
        for r in iflatten_func(restrict, _is_package_instance):
            yield r
    else:
        attrs = frozenset(attrs)
        for r in iflatten_func(restrict, _is_package_instance):
            if invert == attrs.isdisjoint(getattr(r, 'attrs', ())):
                yield r
コード例 #2
0
ファイル: util.py プロジェクト: den4ix/pkgcore
def collect_package_restrictions(restrict, attrs=None, invert=False):
    """Collect PackageRestriction instances inside a restriction.

    :param restrict: package instance to scan
    :param attrs: None (return all package restrictions), or a sequence of
        specific attrs the package restriction must work against.
    """
    if not isinstance(restrict, (list, tuple)):
        restrict = [restrict]
    for r in restrict:
        if not isinstance(r, restriction.base):
            raise TypeError(
                "restrict must be of a restriction.base, not %s: %r" % (
                    r.__class__.__name__, r))
    if attrs is None:
        for r in iflatten_func(restrict, _is_package_instance):
            yield r
    else:
        attrs = frozenset(attrs)
        for r in iflatten_func(restrict, _is_package_instance):
            if invert == attrs.isdisjoint(getattr(r, 'attrs', ())):
                yield r
コード例 #3
0
ファイル: visibility.py プロジェクト: chutz/pkgcheck
def visit_atoms(pkg, stream):
    if not pkg.eapi.options.transitive_use_atoms:
        return iflatten_instance(stream, atom)
    return iflatten_func(stream, _eapi2_flatten)
コード例 #4
0
ファイル: visibility.py プロジェクト: den4ix/pkgcheck
def visit_atoms(pkg, stream):
    if not pkg.eapi.options.transitive_use_atoms:
        return iflatten_instance(stream, atom)
    return iflatten_func(stream, \
        lambda x: isinstance(x,atom) and not isinstance(x,atom._transitive_use_atom))
コード例 #5
0
def visit_atoms(pkg, stream):
    if not pkg.eapi.options.transitive_use_atoms:
        return iflatten_instance(stream, atom)
    return iflatten_func(stream, _eapi2_flatten)