ways.base.cache module¶
A set of functions to register objects to Ways.
-
ways.base.cache.
add_action
(action, name='', context='', assignment='master')[source]¶ Add a created action to Ways.
Parameters: - action (
ways.api.Action
) – The action to add. Action objects are objects that act on Context objects to gather some kind of information. - name (
str
, optional) – A name to identify this action. The name must be unique to this hierarchy/assignment or it might override another pre-existing Action in the same location. If no name is given, the name on the action is tried, instead. Default: ‘’. - context (
ways.api.Context
or str) – The Context or hierarchy of a Context to add this Action to. - assignment (
str
, optional) – The group to add this action to, Default: ‘master’.
Raises: RuntimeError
– If no hierarchy is given and no hierarchy could be found on the given action.RuntimeError
– If no name is given and no name could be found on the given action.ValueError
– If a Context object was given and no hierarchy could be found.
- action (
-
ways.base.cache.
add_descriptor
(description, update=True)[source]¶ Add an object that describes the location of Plugin objects.
Parameters: - description (dict or str) – Some information to create a descriptor object from. If the descriptor is a string and it is a directory on the path, ways.api.FolderDescriptor is returned. If it is an encoded URI, the string is parsed into a dict and processed. If it’s a dict, the dictionary is used, as-is.
- update (
bool
, optional) – If True, add this Descriptor’s plugins to Ways. If False, the user must register a Descriptor’s plugins. Default is True.
-
ways.base.cache.
add_plugin
(path)[source]¶ Load the Python file as a plugin.
Parameters: path (str) – The absolute path to a valid Python file (py or pyc).
-
ways.base.cache.
add_search_path
(description, update=True)¶ Add an object that describes the location of Plugin objects.
Parameters: - description (dict or str) – Some information to create a descriptor object from. If the descriptor is a string and it is a directory on the path, ways.api.FolderDescriptor is returned. If it is an encoded URI, the string is parsed into a dict and processed. If it’s a dict, the dictionary is used, as-is.
- update (
bool
, optional) – If True, add this Descriptor’s plugins to Ways. If False, the user must register a Descriptor’s plugins. Default is True.
-
ways.base.cache.
get_all_plugins
()[source]¶ list[
ways.api.Plugin
]: Every registered plugin.
-
ways.base.cache.
get_assignments
(hierarchy)[source]¶ list[str]: Get the assignments for a hierarchy key in plugins.
-
ways.base.cache.
init_plugins
()[source]¶ Create the Descriptor and Plugin objects found in our environment.
This method ideally should only ever be run once, when Ways first starts.
-
ways.base.cache.
resolve_descriptor
(description)[source]¶ Build a descriptor object from different types of user input.
Parameters: description (dict or str) – Some information to create a descriptor object from. If the descriptor is a string and it is a directory on the path, ways.api.Descriptor is returned. If it is an encoded URI, the string is parsed into a dict and processed. If it’s a dict, the dictionary is used, as-is. Returns: Some descriptor object that works with the given input. Return type: ways.api.Descriptor
or NoneType