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
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
def visit_atoms(pkg, stream): if not pkg.eapi.options.transitive_use_atoms: return iflatten_instance(stream, atom) return iflatten_func(stream, _eapi2_flatten)
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))