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

Scope

Handles the scope/context for Statement objects and derived classes.

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

str

component

The component within a given wrap that is being evaluated; this will be exactly one of kw, obj, anchor, desc, or nm.

Type

str

incl_arg

The keyword argument that would be used to exclude a given component;

Type

str

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 to incl_kw.

Type

str

fallback_to

The default values to fall back to for incl_arg and excl_arg if they are not passed as a keyword argument by the user in Script; defaults to including the base and excluding an empty list.

type

dict

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 from fallback_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 populates check_against_args with the same values if they were provided and fills in defaults from fallback_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.

Parameters

arg (str) – Will either be the value of incl_arg or exclude_arg.

Returns (bool):

Indication of whether any matches were found.

property included(self)

Name is included based on results of last eval().

eval(self, **kwargs)bool

Evaluates filter arguments and updates context accordingly.

Updates the values of is_included, is_excluded, and included.

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.