openpectus.lang.exec.commands

Classes

InterpreterCommandEnum

Commands (instructions of type PCommand) that are executed by the interpreter

CommandRequest

Represents a command request for engine to execute.

Command

Represents a named command.

CommandCollection

Represents a name/command dictionary.

Module Contents

class openpectus.lang.exec.commands.InterpreterCommandEnum

Bases: enum.StrEnum

Commands (instructions of type PCommand) that are executed by the interpreter

BASE = 'Base'
INCREMENT_RUN_COUNTER = 'Increment run counter'
RUN_COUNTER = 'Run counter'
WAIT = 'Wait'
static has_value(value)

Determine if enum has this string value defined. Case sensitive.

Parameters:

value (str)

class openpectus.lang.exec.commands.CommandRequest(name, arguments, source, exec_id=None)

Represents a command request for engine to execute.

Parameters:
  • name (str)

  • arguments (str)

  • source (str)

  • exec_id (uuid.UUID | None)

name: str
arguments: str
exec_id: uuid.UUID | None = None
source: str
command_exec_id: uuid.UUID | None = None
__str__()
Return type:

str

static from_user(name, arguments='')
Parameters:
  • name (str)

  • arguments (str)

Return type:

CommandRequest

static from_interpreter(name, arguments, exec_id)
Parameters:
  • name (str)

  • arguments (str)

  • exec_id (uuid.UUID | None)

Return type:

CommandRequest

class openpectus.lang.exec.commands.Command(name, validatorFn=None, docstring=None, arg_parser=None)

Represents a named command.

Parameters:
name: str
validatorFn = None
docstring = None
arg_parser = None
__str__()
Return type:

str

is_complete()
Return type:

bool

validate_args(args)
Parameters:

args (str)

Return type:

bool

clone()
Return type:

Command

property accepts_arguments: bool
Return type:

bool

class openpectus.lang.exec.commands.CommandCollection(commands=None)

Represents a name/command dictionary.

Parameters:

commands (Iterable[Command] | None)

commands: Dict[str, Command]
__str__()
Return type:

str

property names: List[str]

Return the command names

Return type:

List[str]

__getitem__(tag_name)
Parameters:

tag_name (str)

get(cmd_name)
Parameters:

cmd_name (str)

Return type:

Command

add(cmd, exist_ok=True)

Add command to collection. If command name already exists and exist_ok is False, a ValueError is raised.

Parameters:
with_cmd(cmd)
Parameters:

cmd (Command)

has(cmd_name)
Parameters:

cmd_name (str)

Return type:

bool

clone()

Returns a deep clone of the collection.

Return type:

CommandCollection

to_list()
merge_with(other)

Returns a new CommandCollection with the combined commands of both collections.

In case of duplicate commands names, tags from other collection are used.

Parameters:

other (CommandCollection)

Return type:

CommandCollection