pkgcore.restrictions.restriction module

base restriction class

class pkgcore.restrictions.restriction.AlwaysBool(*args: Hashable, disable_inst_caching=False, **kwargs: Hashable)[source]

Bases: base

restriction that always yields a specific boolean

force_False(*a, **kw)[source]
force_True(*a, **kw)[source]
match(*a, **kw)[source]
negate: bool
type: T_restriction
class pkgcore.restrictions.restriction.AnyMatch(*args: Hashable, disable_inst_caching=False, **kwargs: Hashable)[source]

Bases: base

Apply a nested restriction to every item in a sequence.

match(val)[source]
negate
restriction
type: T_restriction
class pkgcore.restrictions.restriction.FakeType(*args: Hashable, disable_inst_caching=False, **kwargs: Hashable)[source]

Bases: base

wrapper to wrap and fake a node_type

match(*a, **kw)[source]
type: T_restriction
class pkgcore.restrictions.restriction.Negate(*args: Hashable, disable_inst_caching=False, **kwargs: Hashable)[source]

Bases: base

wrap and negate a restriction instance

match(*a, **kw)[source]
type: T_restriction
type pkgcore.restrictions.restriction.T_restriction = str
class pkgcore.restrictions.restriction.base(*args: Hashable, disable_inst_caching=False, **kwargs: Hashable)[source]

Bases: SlotsPicklingMixin, Simple, WeaklyCachedABC

base restriction matching object.

all derivatives should be __slots__ based (lot of instances may wind up in memory).

force_False(*arg, **kwargs) bool[source]
force_True(*arg, **kwargs) bool[source]
abstractmethod match(*arg, **kwargs) bool[source]
package_matching: ClassVar[bool] = False
type: T_restriction
pkgcore.restrictions.restriction.curry_node_type(cls, node_type: T_restriction, extradoc=None)[source]

Helper function for creating restrictions of a certain type.

This uses functools.partial to pass a node_type to the wrapped class, and extends the docstring.

Parameters:
  • cls – callable (usually a class) that is wrapped.

  • node_type – value passed as node_type.

  • extradoc – addition to the docstring. Defaults to “Automatically set to %s type.” % node_type

Returns:

a wrapped callable.