commands.typed module

exception commands.typed.ArgumentError(message='')[source]

Bases: commands.typed.ValidationError

exception commands.typed.ArgumentNumberMismatch(message='')[source]

Bases: commands.typed.ArgumentError

exception commands.typed.InvalidArgumentValue(message='')[source]

Bases: commands.typed.ArgumentError

exception commands.typed.SubCommandError(message='')[source]

Bases: commands.typed.ValidationError

exception commands.typed.SubCommandExpectedError(message='')[source]

Bases: commands.typed.SubCommandError

exception commands.typed.SubCommandNotFound(message='')[source]

Bases: commands.typed.SubCommandError

class commands.typed.CommandInfo(command, index=None, team_only=None)[source]

Bases: object

Stores command information for typed commands.

__init__(command, index=None, team_only=None)[source]

Initializes the instance.

Parameters:
  • command (Command) – The actual Command instance.
  • index (int) – The index of the player that issued the command. None, if it’s a server command.
  • team_only (bool) – Indicates whether the command was issued in team chat. None, if it’s a server or client command.
class commands.typed.CommandNode(commands, params, callback, description, permission, fail_callback, requires_registration)[source]

Bases: commands.typed.Node

__init__(commands, params, callback, description, permission, fail_callback, requires_registration)[source]

Initialize the object.

static _param_to_str(param)[source]

Represent a parameter as a string.

Return type:str
signature

Return the full signature of a command.

Return type:str
class commands.typed.CommandParser(commands=None, description=None)[source]

Bases: commands.typed.Store

_remove_command(commands)[source]

Remove a command.

Parameters:commands (list) – Command to remove.
Raises:ValueError – Raised if the node does not exist.
Returns:Return whether the base command needs to be unregistered.
Return type:bool
_validate_command(command_name)[source]

Validate a command name.

Parameters:command_name (str) – The command name to check.
Raises:ValueError – Raised if the command name is invalid.
_validate_commands(commands)[source]

Validate a string, list or tuple of commands.

Parameters:

str/list/tuple – The command name or command path to validate.

Raises:
  • TypeError – Raised if commands is not a str, list or tuple.
  • ValueError – Raised if commands is an empty list or tuple.
add_command(commands, params, callback, description=None, permission=None, fail_callback=None)[source]

Add a command to the parser.

Parameters:
  • commands (str/list/tuple) – Command to register.
  • params (iterable) – Parameters of the command.
  • callback (callable) – The callback for the command.
  • description (str) – Description of the command.
  • permission (str) – Required permission to use the command.
  • fail_callback (callable) – Callback that gets called if authorization failed.
Return type:

CommandNode

clean_command(command, args)[source]

Clean a command and its passed arguments.

Parameters:
  • command (CommandNode) –
  • args (iterable) – The arguments to clean.
Return type:

list

Raises:
  • InvalidArgumentValue – Raised if the value is invalid for an argument.
  • ArgumentNumberMismatch – Raised if too many/less arguments have been passed.
get_command(commands)[source]

Return a command.

Parameters:str/list/tuple – Command to search.
Return type:CommandNode

See also

get_node()

get_node(commands)[source]

Return a node.

Parameters:str/list/tuple – Node to seach.
Raises:ValueError – Raised if the node does not exist.
Return type:Node
parse_command(command)[source]

Parse a Command object.

Splits the command into the actual command and its arguments.

Parameters:

command (Command) – A command to parse.

Raises:
  • SubCommandNotFound – Raised if a sub command was not found.
  • SubCommandExpected – Raised if a sub command was expected, but more arguments have been passed.
Return type:

tuple

remove_command(commands)[source]

Remove a command.

Parameters:str/list/tuple – Command to remove.
set_node_description(commands, description)[source]

Set the description of a node.

Parameters:str/list/tuple – Node to seach.
Raises:ValueError – Raised if the node does not exist.
class commands.typed.Node(commands, description)[source]

Bases: object

__init__(commands, description)[source]
signature

Return the signature of the node.

Return type:str
class commands.typed.Store(commands=None, description=None)[source]

Bases: commands.typed.Node, dict

__init__(commands=None, description=None)[source]
help_text

Return the help text of the node.

Return type:str
signature

Return the signature of the node.

Return type:str
class commands.typed.TypedClientCommand(commands, permission=None, fail_callback=None)[source]

Bases: commands.typed._TypedPlayerCommand

Decorator class to create typed client commands.

static send_message(command_info, message)[source]
manager = <commands.client._ClientCommandManager object>
parser = {}
class commands.typed.TypedSayCommand(commands, permission=None, fail_callback=None)[source]

Bases: commands.typed._TypedPlayerCommand

Decorator class to create typed say commands.

static send_message(command_info, message)[source]
manager = <commands.say._SayCommandManager object>
parser = {}
class commands.typed.TypedServerCommand(commands, permission=None, fail_callback=None)[source]

Bases: commands.typed._TypedCommand

Decorator class to create typed server commands.

static send_message(command_info, message)[source]
manager = <commands.server._ServerCommandManager object>
parser = {'sp': {'delay': <commands.typed.CommandNode object>, 'credits': <commands.typed.CommandNode object>, 'help': <commands.typed.CommandNode object>, 'info': <commands.typed.CommandNode object>, 'auth': {'backend': {'set': <commands.typed.CommandNode object>, 'list': <commands.typed.CommandNode object>}, 'permission': {'player': {'add': <commands.typed.CommandNode object>, 'remove': <commands.typed.CommandNode object>, 'add_parent': <commands.typed.CommandNode object>, 'remove_parent': <commands.typed.CommandNode object>, 'test': <commands.typed.CommandNode object>}, 'parent': {'add': <commands.typed.CommandNode object>, 'remove': <commands.typed.CommandNode object>, 'add_parent': <commands.typed.CommandNode object>, 'remove_parent': <commands.typed.CommandNode object>, 'list': <commands.typed.CommandNode object>}}}, 'docs': {'create': <commands.typed.CommandNode object>, 'generate': <commands.typed.CommandNode object>, 'build': <commands.typed.CommandNode object>}, 'dump': {'class_info': <commands.typed.CommandNode object>, 'convars': <commands.typed.CommandNode object>, 'datamaps': <commands.typed.CommandNode object>, 'server_classes': <commands.typed.CommandNode object>, 'string_tables': <commands.typed.CommandNode object>, 'weapon_scripts': <commands.typed.CommandNode object>}, 'plugin': {'load': <commands.typed.CommandNode object>, 'unload': <commands.typed.CommandNode object>, 'reload': <commands.typed.CommandNode object>, 'list': <commands.typed.CommandNode object>}}}
commands.typed.filter_str(expr)[source]