Doer Manager¶
The DoerManager
class is responsible for orchestrating the doers.
Commands for the different types of doers, for example the Shell
doer, are provided to this class, which are then parsed and converted to their
respective doer instances. The default doer is also taken into account for
commands that don’t explicitly specify a doer.
As an example, the following code would parse out the command specified as the
first argument and create a Shell
doer from it.
>>> manager = DoerManager(['shell:echo "%f changed!"'], Shell)
In the above case, the shell:
prefix wasn’t necessary, as the default doer
(the second argument) was already set to Shell
.
All of the doers can be run by calling the run_doers()
method.
>>> manager.run_doers('my_file.txt')
-
class
watch_do.doer_manager.
DoerManager
(commands, default_doer)[source]¶ This class creates and manages doers.
Commands are passed in, which then get parsed and converted to instances of doers. All doers can be run using the
run_doers()
method with relevant output returned.Initialise the
DoerManager
and parse all commands.The commands that get passed into this class are parsed (removing their
doer:
prefix if required) and have the relevant doer instances created for them.Parameters: - commands (list) – A list of strings containing the commands to
create doers for. Each command (str) in the list of commands
should be prefixed with
doer:
, where ‘doer’ is the name of the doer (i.e.shell
). If the command is not prefixed withdoer:
thedefault_doer
will be used. - default_doer (
Doer
) – A reference to a doer class to use as the default doer if one is not explicitly specified using thedoer:
prefix.
-
commands
¶ list – The list of stings that this
DoerManager
is managing.
-
doers
¶ list – The doers that were created as a result of passing the commands.
- commands (list) – A list of strings containing the commands to
create doers for. Each command (str) in the list of commands
should be prefixed with