ways package

Ways is split into two main sections. ways and ways.api. Of the two, 99% of all your work is going to use classes and functions out of ways.api but in the exceptional case where you need to do something special, You’d use the parent module’s functions.

Main Module

ways.api is where almost every function and class is added to and contains everything that you’d need to work with Ways.

Module contents

The main location where loaded plugin and action objects are managed.

ways.add_plugin(plugin, assignment='master')[source]

Add a plugin to Ways.

Parameters:
  • plugin (ways.api.Plugin) – The plugin to add.
  • assignment (str, optional) – The assignment of the plugin. Default: ‘master’.
ways.check_plugin_uuid(info)[source]

Make sure that the plugin UUID is not already taken.

Parameters:info (ways.api.DataPlugin or dict[str]) – Data that may become a proper plugin.
Raises:RuntimeError – If the plugin’s UUID is already taken.
ways.clear()[source]

Remove all Ways plugins and actions.

ways.get_action(name, hierarchy, assignment='master')[source]

Find an action based on its name, hierarchy, and assignment.

The first action that is found for the hierarchy is returned.

Parameters:
  • name (str) – The name of the action to get. This name is assigned to the action when it is defined.
  • hierarchy (tuple[str]) – The location of where this Action object is.
  • assignment (str, optional) – The group that the Action was assigned to. Default: ‘master’.
Returns:

The found Action object.

Return type:

ways.api.Action or NoneType

ways.get_action_names(hierarchy, assignment='master')[source]

Get the names of all actions available for some plugin hierarchy.

Parameters:
  • hierarchy (tuple[str]) – The specific description to get plugin/action objects from.
  • assignment (str, optional) – The group to get items from. Default: ‘master’.
Returns:

The names of all actions found for the Ways object.

Return type:

list[str]

ways.get_actions(hierarchy, assignment='master', duplicates=False)[source]

Get back all of the action objects for a plugin hierarchy.

Parameters:
  • hierarchy (tuple[str]) – The specific description to get plugin/action objects from.
  • assignment (str, optional) – The group to get items from. Default: ‘master’.
  • duplicates (bool, optional) – If True, The first Action that is found will be returned. If False, all actions (including parent actions with the same name) are all returned. Default is False.
Returns:

The actions in the hierarchy.

Return type:

list[ways.api.Action or callable]

ways.get_actions_info(hierarchy, assignment='master')[source]

Get the names and objects for all Action objects in a hierarchy.

Parameters:
  • hierarchy (tuple[str]) – The specific description to get plugin/action objects from.
  • assignment (str, optional) – The group to get items from. Default: ‘master’.
Returns:

ways.api.Action or callable]:

The name of the action and its associated object.

Return type:

dict[str

ways.get_actions_iter(hierarchy, assignment='master')[source]

Get the actions at a particular hierarchy.

Parameters:
  • hierarchy (tuple[str]) – The location of where this Plugin object is.
  • assignment (str, optional) – The group that the PLugin was assigned to. Default: ‘master’. If assignment=’‘, all plugins from every assignment is queried.
Yields:

dict[str, ways.api.Action] – The actions for some hierarchy.

ways.get_known_platfoms()[source]

Find the platforms that Ways sees.

This will return back the platforms defined in the WAYS_PLATFORMS environment variable. If WAYS_PLATFORMS isn’t defined, a default set of platforms is returned.

Returns:
All of the platforms.
Default: {‘darwin’, ‘java’, ‘linux’, ‘windows’}
Return type:set[str]
ways.get_parse_order()[source]

list[str]: The order to try all of the parsers registered by the user.

ways.get_plugins(hierarchy, assignment='master')[source]

Find an plugin based on its name, hierarchy, and assignment.

Every plugin found at every level of the given hierarchy is collected and returned.

Parameters:
  • name (str) – The name of the plugin to get. This name needs to be assigned to the plugin when it is defined.
  • hierarchy (tuple[str]) – The location of where this Plugin object is.
  • assignment (str, optional) – The group that the PLugin was assigned to. Default: ‘master’. If assignment=’‘, all plugins from every assignment is queried.
Returns:

The found plugins, if any.

Return type:

list[ways.api.Plugin]

ways.get_priority()[source]

Determine the order that assignments are searched through for plugins.

This list is controlled by the WAYS_PRIORITY variable.

For example, os.environ[‘WAYS_PRIORITY’] = ‘master:job’. Since job plugins come after master plugins, they are given higher priority

Todo

Give a recommendation (in docs) for where to read more about this.

Returns:The assignments to search through.
Return type:tuple[str]