snowmobile.core.scope
¶
Defines the Scope for a given statement; invoked internally as the scope/context of statements being considered by a snowmobile.Script
is being altered through script.filter()
Module Contents¶
Classes¶
Handles the scope/context for |
- class
snowmobile.core.scope.
Scope
(arg: str, base: str)¶ Bases:
snowmobile.core.Generic
Handles the scope/context for
Statement
objects and derived classes.Should never be interacted with from the user-facing API.
-
base
¶ The left-most word within a statement wrap. For generic st this will be the keyword and for QA statements this will be the literal word
qa
.- Type
-
component
¶ The component within a given wrap that is being evaluated; this will be exactly one of kw, obj, anchor, desc, or nm.
- Type
-
excl_arg
¶ The keyword argument that would be used to exclude a given component; this would be the same as the above example except the value would be
excl_kw
as opposed toincl_kw
.- Type
-
fallback_to
¶ - provided_args (dict):
The set of keyword arguments provided at the time of the last call to
eval()
.- check_against_args (dict):
The set of keyword arguments checked against at the time of the last call to
eval()
; will use provided arguments if they exist and the arguments fromfallback_to
otherwise.- is_included (bool):
Name is included based on the results of the last call to
eval()
.- is_excluded (bool):
Name is excluded based on the results of the last call to
eval()
.
Instantiates a
Scope
object.-
parse_kwargs
(self, **kwargs) → None¶ Parses all filter arguments looking for those that match its base.
Looks for include/exclude arguments within kwargs, populating
provided_args
with those that were provided and populatescheck_against_args
with the same values if they were provided and fills in defaults fromfallback_to
otherwise.- Parameters
**kwargs – Keyword arguments passed to
Script.filter()
(e.g. incl_kw, excl_kw, ..)
-
matches_patterns
(self, arg: str) → bool¶ Returns indication of if
base
matches a given set of patterns.- Returns (bool):
Indication of whether any matches were found.
-
eval
(self, **kwargs) → bool¶ Evaluates filter arguments and updates context accordingly.
Updates the values of
is_included
,is_excluded
, andincluded
.- Parameters
**kwargs – Keyword arguments passed to
Script.filter()
(e.g. incl_kw, excl_kw, ..)
- Returns (bool):
Indicator of whether or not the statement should be included/excluded based on the context/keyword arguments pr.
-