so_magic.utils.commands module¶
- class so_magic.utils.commands.Command(receiver, method: str, *args)[source]¶
Bases:
so_magic.utils.commands.BaseCommand
An runnable/executable Command that acts as a prototype through the ‘copy’ python magic function.
When a command instance is invoked with ‘copy’, the receiver is copied explicitly in a shallow way. The rest of the command arguments are assumed to be performance invariant (eg it is not expensive to copy the ‘method’ attribute, which is a string) and are handled automatically.
- class so_magic.utils.commands.CommandHistory[source]¶
Bases:
object
The global command history is just a stack; supports ‘push’ and ‘pop’ methods.
- push(command: so_magic.utils.commands.Command)[source]¶
- property stack¶
- class so_magic.utils.commands.CommandInterface[source]¶
Bases:
abc.ABC
Standalone command, encapsulating all logic and data needed, required for execution.
- class so_magic.utils.commands.Invoker(history: so_magic.utils.commands.CommandHistory)[source]¶
Bases:
object
A class that simply executes a command and pushes it into its internal command history stack.
- Parameters
history (CommandHistory) – the command history object which acts as a stack
- execute_command(command: so_magic.utils.commands.Command)[source]¶