nopasaran.interpreters.action_interpreter.ActionInterpreter¶
- class nopasaran.interpreters.action_interpreter.ActionInterpreter(completekey='tab', stdin=None, stdout=None)¶
Bases:
InterpreterA custom ActionInterpreter class that inherits from Interpreter. This class interprets actions in the context of a command-line interface.
- __init__(completekey='tab', stdin=None, stdout=None)¶
Instantiate a line-oriented interpreter framework.
The optional argument ‘completekey’ is the readline name of a completion key; it defaults to the Tab key. If completekey is not None and the readline module is available, command completion is done automatically. The optional arguments stdin and stdout specify alternate input and output file objects; if not specified, sys.stdin and sys.stdout are used.
Methods
__init__([completekey, stdin, stdout])Instantiate a line-oriented interpreter framework.
cmdloop([intro])Repeatedly issue a prompt, accept input, parse an initial prefix off the received input, and dispatch to action methods, passing them the remainder of the line as argument.
columnize(list[, displaywidth])Display a list of strings as a compact set of columns.
complete(text, state)Return the next possible completion for 'text'.
complete_help(*args)completedefault(*ignored)Method called to complete an input line when no command-specific complete_*() method is available.
completenames(text, *ignored)default(line, variable)Handle the default behavior when an unknown command is encountered.
do_help(arg)List available commands with "help" or detailed help with "help cmd".
Called when an empty line is entered in response to the prompt.
evaluate(line, state_variables)Evaluate the action line using the provided state variables.
get_names()onecmd(line, variable)Run a single command with the provided line and variable.
parseline(line)Parse the line into a command name and a string containing the arguments.
postcmd(stop, line)Hook method executed just after a command dispatch is finished.
postloop()Hook method executed once when the cmdloop() method is about to return.
precmd(line)Hook method executed just before the command line is interpreted, but after the input prompt is generated and issued.
preloop()Hook method executed once when the cmdloop() method is called.
print_topics(header, cmds, cmdlen, maxcol)Attributes
doc_headerdoc_leaderidentcharsintrolastcmdmisc_headernohelppromptrulerundoc_headeruse_rawinput- cmdloop(intro=None)¶
Repeatedly issue a prompt, accept input, parse an initial prefix off the received input, and dispatch to action methods, passing them the remainder of the line as argument.
- columnize(list, displaywidth=80)¶
Display a list of strings as a compact set of columns.
Each column is only as wide as necessary. Columns are separated by two spaces (one was not legible enough).
- complete(text, state)¶
Return the next possible completion for ‘text’.
If a command has not been entered, then complete against command list. Otherwise try to call complete_<command> to get list of completions.
- completedefault(*ignored)¶
Method called to complete an input line when no command-specific complete_*() method is available.
By default, it returns an empty list.
- default(line, variable)¶
Handle the default behavior when an unknown command is encountered.
- Args:
line (str): The unknown command line. variable: The variable to use during handling.
- Raises:
Exception: Parsing error with the unknown argument.
- do_help(arg)¶
List available commands with “help” or detailed help with “help cmd”.
- emptyline()¶
Called when an empty line is entered in response to the prompt.
If this method is not overridden, it repeats the last nonempty command entered.
- classmethod evaluate(line, state_variables)¶
Evaluate the action line using the provided state variables.
- Args:
line (str): The action line to evaluate. state_variables: The state variables to use during evaluation.
- Returns:
The result of the evaluation.
- onecmd(line, variable)¶
Run a single command with the provided line and variable.
- Args:
line (str): The command line to execute. variable: The variable to use during execution.
- Returns:
The result of the command execution.
- parseline(line)¶
Parse the line into a command name and a string containing the arguments. Returns a tuple containing (command, args, line). ‘command’ and ‘args’ may be None if the line couldn’t be parsed.
- postcmd(stop, line)¶
Hook method executed just after a command dispatch is finished.
- postloop()¶
Hook method executed once when the cmdloop() method is about to return.
- precmd(line)¶
Hook method executed just before the command line is interpreted, but after the input prompt is generated and issued.
- preloop()¶
Hook method executed once when the cmdloop() method is called.