Package command_system :: Module framework
[hide private]
[frames] | no frames]

Module framework

source code

Provides a tiny framework with simple, yet powerful and extensible architecture to implement commands in a streight and flexible, declarative way.
Classes [hide private]
  CommandHost
Command host is a hub between numerous command processors and command containers. Aimed to participate in a dispatching process in order to provide clean and transparent architecture.
  CommandContainer
Command container is an entity which holds defined commands, allowing them to be dispatched and proccessed correctly. Each command container may be bound to a one or more command hosts.
  CommandProcessor
Command processor is an immediate command emitter. It does not participate in the dispatching process directly, but must define a host to bound to.
  Command
Functions [hide private]
 
command(*names, **properties)
A decorator for defining commands in a declarative way. Provides facilities for setting command's names and properties.
source code
 
doc(text)
This decorator is used to bind a documentation (a help) to a command.
source code
Variables [hide private]
  __package__ = 'command_system'

Imports: re, FunctionType, getargspec, getdoc, Host, Container, get_command, list_commands, parse_arguments, adapt_arguments, DefinitionError, CommandError, NoCommandError


Function Details [hide private]

command(*names, **properties)

source code 

A decorator for defining commands in a declarative way. Provides facilities for setting command's names and properties.

Names should contain a set of names (aliases) by which the command can be reached. If no names are given - the the native name (the one extracted from the command handler) will be used.

If native=True is given (default) and names is non-empty - then the native name of the command will be prepended in addition to the given names.

If usage=True is given (default) - then command help will be appended with autogenerated usage info, based of the command handler arguments introspection.

If source=True is given - then the first argument of the command will receive the source arguments, as a raw, unprocessed string. The further mapping of arguments and options will not be affected.

If raw=True is given - then command considered to be raw and should define positional arguments only. If it defines only one positional argument - this argument will receive all the raw and unprocessed arguments. If the command defines more then one positional argument - then all the arguments except the last one will be processed normally; the last argument will get what is left after the processing as raw and unprocessed string.

If empty=True is given - this will allow to call a raw command without arguments.

If extra=True is given - then all the extra arguments passed to a command will be collected into a sequence and given to the last positional argument.

If overlap=True is given - then all the extra arguments will be mapped as if they were values for the keyword arguments.

If expand=True is given (default) - then short, one-letter options will be expanded to a verbose ones, based of the comparison of the first letter. If more then one option with the same first letter is given - then only first one will be used in the expansion.

doc(text)

source code 
This decorator is used to bind a documentation (a help) to a command.

Variables Details [hide private]

__package__

Value:
'command_system'