commands Package

commands Package

base Module

The module defining common functionality and base classes for all email control commands.

class distro_tracker.mail.control.commands.base.Command(*args)[source]

Bases: object

Base class for commands. Instances of this class can be used for no-op commands.

META = {}

Meta information about the command, given as key/value pairs. Expected keys are:

  • description - Description of the command which will be shown in the
    help output
  • name - Name of the command. Makes it possible to match command lines
    in control messages to command classes since each command line starts with the name of the command.
  • aliases - List of alternative names for the command
  • position - Preferred position in the help output
REGEX_LIST = ()

A list of regular expressions which, when matched to a string, identify a command. Additionally, any named group in the regular expression should exactly match the name of the parameter in the constructor of the command. If unnamed groups are used, their order must be the same as the order of parameters in the constructor of the command. This is very similar to how Django handles linking views and URLs.

It is only necessary to list the part of the command’s syntax to capture the parameters, while the name and all aliases given in the META dict are automatically assumed when matching a string to the command.

error(message, *args)[source]

Adds an error message to the command’s reply.

Parameters:message (string) – Message to include in the reply
get_command_text(*args)[source]

Returns a string representation of the command.

handle()[source]

Performs the necessary steps to execute the command.

is_valid()[source]
list_reply(items, bullet='*')[source]

Includes a list of items in the reply. Each item is converted to a string before being output.

Parameters:
  • items – An iterable of items to be included in the form of a list in the reply.
  • bullet – The character to be used as the “bullet” of the list.
classmethod match_line(line)[source]

Class method to check whether the given line matches the command.

Parameters:line – The line to check whether it matches the command.
render_reply()[source]

Returns a string representing the command’s reply.

reply(message, *args)[source]

Adds a message to the command’s reply.

Parameters:message (string) – Message to include in the reply
warning(message, *args)[source]

Adds a warning to the command’s reply.

Parameters:message (string) – Message to include in the reply
class distro_tracker.mail.control.commands.base.MetaCommand(name, bases, dct)[source]

Bases: type

Meta class for Distro Tracker Commands.

Transforms the Command.REGEX_LIST given in a Command sublclass to include all aliases of the command. When implementing a Command subclass, it is not necessary to include a separate regex for each command alias or a long one listing every option.

confirmation Module

keywords Module

misc Module