ways.parsing.trace module¶
A module to help you debug all of your Context, Plugin, and Action objects.
-
ways.parsing.trace.
get_action_hierarchies
(action)[source]¶ Get the Context hierachies that this Action is registered for.
Note
get_action_hierarchies will return every Action that matches the given Action name. So if multiple classes/functions are all registered under the same name, then every hierarchy that those Actions use will be returned. However, if a object like a function or class that was registered, only that object’s hierarchies will be returned.
Parameters: action (str or class or callable) – The action to get the hierachies of. Returns: The hierarchies for the given Action. Return type: set[tuple[str]]
-
ways.parsing.trace.
get_all_action_hierarchies
()[source]¶ Organize every Action that is registered into Ways by object and hierarchy.
Returns: - dict[str: str or set]]:
- Actions are stored as either classes or functions. Each Action’s value is a dict which contains the hierachies that the Action is applied to and its registered name.
Return type: dict[class or callable
-
ways.parsing.trace.
get_all_assignments
()[source]¶ set[str]: All of the assignments found in our environment.
-
ways.parsing.trace.
get_all_hierarchies
()[source]¶ set[tuple[str]]: The Contexts that have plugins in our environment.
-
ways.parsing.trace.
get_all_hierarchy_trees
(full=False)[source]¶ Get a description of every Ways hierarchy.
Examples
>>> get_all_hierarchy_trees(full=True) >>> { >>> ('foo', ): { >>> ('foo', 'bar'): { >>> ('foo' 'bar', 'fizz'): {}, >>> }, >>> ('foo', 'something', 'buzz'): { >>> ('foo', 'something', 'buzz', 'thing'): {}, >>> }, >>> }, >>> }
>>> get_all_hierarchy_trees(full=False) >>> { >>> 'foo': { >>> 'bar': { >>> 'fizz': {}, >>> }, >>> 'something': { >>> 'buzz': { >>> 'thing': {}, >>> }, >>> }, >>> }, >>> }
Parameters: full ( bool
, optional) – If True, each item in the dict will be its own hierarchy. If False, only a single part will be written. See examples for details. Default is False.Returns: The entire hierarchy. Return type: collections.defaultdict[str]
-
ways.parsing.trace.
get_child_hierarchies
(hierarchy)[source]¶ list[tuple[str]]: Get hierarchies that depend on the given hierarchy.
-
ways.parsing.trace.
get_child_hierarchy_tree
(hierarchy, full=False)[source]¶ Get all of the hierarchies that inherit the given hierarchy.
Examples
>>> get_all_hierarchy_trees(full=True) >>> { >>> ('foo', ): { >>> ('foo', 'bar'): { >>> ('foo' 'bar', 'fizz'): {}, >>> }, >>> ('foo', 'something', 'buzz'): { >>> ('foo', 'something', 'buzz', 'thing'): {}, >>> }, >>> }, >>> }
>>> get_all_hierarchy_trees(full=False) >>> { >>> 'foo': { >>> 'bar': { >>> 'fizz': {}, >>> }, >>> 'something': { >>> 'buzz': { >>> 'thing': {}, >>> }, >>> }, >>> }, >>> }
Parameters: - hierarchy (tuple[str]) – The hierarchy to get the child hierarchy items of.
- full (
bool
, optional) – If True, each item in the dict will be its own hierarchy. If False, only a single part will be written. See examples for details. Default is False.
Returns: The entire hierarchy.
Return type: collections.defaultdict[str]
-
ways.parsing.trace.
startswith
(base, leaf)[source]¶ Check if all tuple items match the start of another tuple.
Raises: ValueError
– If base is shorted than leaf.
-
ways.parsing.trace.
trace_action_names
(obj, *args, **kwargs)[source]¶ Get the names of all actions available to a Ways object.
Parameters: - obj (
ways.api.Action
orways.api.AssetFinder
orways.api.Context
orways.api.Find
) – The object to get the action names of. - *args (list) – Position args to pass to ways.get_action_names.
- **kwargs (dict[str]) – Keyword args to pass to ways.get_action_names.
Returns: The names of all actions found for the Ways object.
Return type: list[str]
- obj (
-
ways.parsing.trace.
trace_actions
(obj, *args, **kwargs)[source]¶ Get actions that are assigned to the given object.
Parameters: - obj (
ways.api.Action
orways.api.AssetFinder
orways.api.Context
orways.api.Find
) – The object to get the actions of. - *args (list) – Position args to pass to ways.get_actions.
- **kwargs (dict[str]) – Keyword args to pass to ways.get_actions.
Returns: The actions in the hierarchy.
Return type: list[
ways.api.Action
or callable]- obj (
-
ways.parsing.trace.
trace_actions_table
(obj, *args, **kwargs)[source]¶ Find the names and objects of every action registered to Ways.
Parameters: - obj (
ways.api.Action
orways.api.AssetFinder
orways.api.Context
orways.api.Find
) – The object to get the available actions table of. - *args (list) – Position args to pass to ways.get_actions_info..
- **kwargs (dict[str]) – Keyword args to pass to ways.get_action_info.
Returns: The names and actions of an object.
Return type: dict[str,
ways.api.Action
or callable]- obj (
-
ways.parsing.trace.
trace_all_descriptor_results
()[source]¶ list[dict[str]]: The load/failure information about each Descriptor.
-
ways.parsing.trace.
trace_all_load_results
()[source]¶ Get the load results of every plugin and descriptor.
If the UUID for a Descriptor cannot be found, Ways will automatically assign it a UUID.
Using this function we can check 1. What plugins that Ways found and tried to load. 2. If our plugin loaded and, if not, why.
Returns: The main dictionary has two keys, “descriptors” and “plugins”. Each key has an OrderedDict that contains the UUID of each Descriptor and plugin and their objects. Return type: dict[str, collections.OrderedDict
[str, dict[str]]]
-
ways.parsing.trace.
trace_all_plugin_results
()[source]¶ list[dict[str]]: The results of each plugin’s load results.
-
ways.parsing.trace.
trace_context
(obj)[source]¶ Get a Context, using some object.
This function assumes that the given object is a Ways class that only has 1 Context added to it (not several).
Parameters: obj – Some Ways object instance. Returns: The found Context. Return type: ways.api.Context
or NoneType
-
ways.parsing.trace.
trace_hierarchy
(obj)[source]¶ Try to find a hierarchy for the given object.
Parameters: obj ( ways.api.Action
orways.api.AssetFinder
orways.api.Context
orways.api.Find
) – The object to get the hierarchy of.Returns: The hierarchy of some object. Return type: tuple[str]