class SandboxMatcher: (source)
Constructor: SandboxMatcher.nested_child(path, child)
Matcher that is used to match modules and members during restriction and pass through checks.
This class is intentionally immutable. Changes need to be made as new instances.
Static Method | nested |
Create a matcher where the given child is put at the given path. |
Method | __or__ |
Combine this matcher with another. |
Method | __post |
Post initialization validations. |
Method | access |
Perform a match check and return matcher. |
Method | child |
Return a child matcher for the given path. |
Method | match |
Perform a match check. |
Method | with |
Create new matcher with the given child path removed. |
Class Variable | access |
Immutable set of names to match access. |
Class Variable | all |
Shortcut for an always-matched matcher. |
Class Variable | all |
Shortcut for an always-runtime-matched matcher. |
Class Variable | all |
Shortcut for a matcher that matches any use . |
Class Variable | all |
Shortcut for a matcher that matches any use at runtime. |
Class Variable | children |
Immutable mapping of child matchers. |
Class Variable | leaf |
Override message to use in error/warning. Defaults to a common message. This is only applicable to leafs, so this must only be set when match_self is True and this matcher is on children of a parent. |
Class Variable | leaf |
If set, issues a warning instead of raising an error. This is only applicable to leafs, so this must only be set when match_self is True and this matcher is on children of a parent. |
Class Variable | match |
If True, this matcher matches. |
Class Variable | none |
Shortcut for a never-matched matcher. |
Class Variable | only |
If True, any matches on this matcher only apply at runtime, not import time. |
Class Variable | use |
Immutable set of names to match use. |
def nested_child(path:
Sequence[ str]
, child: SandboxMatcher
) -> SandboxMatcher
:
(source)
¶
Create a matcher where the given child is put at the given path.
Parameters | |
path:Sequence[ | Path to the child. |
child:SandboxMatcher | Child matcher to set |
Returns | |
SandboxMatcher | Created matcher. |
RestrictionContext
, *child_path: str
, include_use: bool
= False) -> Optional[ SandboxMatcher]
:
(source)
¶
Perform a match check and return matcher.
Parameters | |
context:RestrictionContext | Current restriction context. |
*childstr | Full path to the child being accessed. |
includebool | Whether to include the use set in the check. |
Returns | |
Optional[ | The matcher if matched. |
Return a child matcher for the given path.
Unlike match_access
, this will match if in py`use` in
addition to access
. If in neither, it uses the child mapping.
Parameters | |
*childstr | Full path to the child to get matcher for. |
Returns | |
Optional[ | Matcher that can be used to check children. |
Create new matcher with the given child path removed.
Traverses the child mapping, if present, until on leaf of path where it
is removed from access
, use
, and
children
.
Parameters | |
*childstr | Full path to the child to remove restrictions for. |
Returns | |
SandboxMatcher | Copied matcher from this matcher without this child restricted. |
Immutable set of names to match access.
This is often only used for pass through checks and not member restrictions.
If this is used for member restrictions, even importing/accessing the value
will fail as opposed to use
which is for when it is used.
An string containing a single asterisk can be used to match all.
Override message to use in error/warning. Defaults to a common message. This is only applicable to leafs, so this must only be set when match_self is True and this matcher is on children of a parent.
If set, issues a warning instead of raising an error. This is only applicable to leafs, so this must only be set when match_self is True and this matcher is on children of a parent.