Shortened a couple of things in the command system

This commit is contained in:
Alexander Cherniuk 2010-08-05 14:06:36 +03:00
parent da1f16b0c9
commit 09e1742bcc
3 changed files with 14 additions and 14 deletions

View File

@ -226,9 +226,9 @@ def command(*names, **properties):
can be reached. If no names are given - the the native name (the one
extracted from the command handler) will be used.
If include_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 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
@ -256,14 +256,14 @@ def command(*names, **properties):
If overlap=True is given - then all the extra arguments will be
mapped as if they were values for the keyword arguments.
If expand_short=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.
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.
"""
names = list(names)
include_native = properties.get('include_native', True)
native = properties.get('native', True)
usage = properties.get('usage', True)
source = properties.get('source', False)
@ -271,7 +271,7 @@ def command(*names, **properties):
empty = properties.get('empty', False)
extra = properties.get('extra', False)
overlap = properties.get('overlap', False)
expand_short = properties.get('expand_short', True)
expand = properties.get('expand', True)
if empty and not raw:
raise DefinitionError("Empty option can be used only with raw commands")
@ -286,7 +286,7 @@ def command(*names, **properties):
'extra': extra,
'overlap': overlap,
'empty': empty,
'expand_short': expand_short
'expand': expand
}
def decorator(handler):
@ -297,9 +297,9 @@ def command(*names, **properties):
command = Command(handler, *names, **properties)
# Extract and inject a native name if either no other names are
# specified or include_native property is enabled, while making
# specified or native property is enabled, while making
# sure it is going to be the first one in the list.
if not names or include_native:
if not names or native:
names.insert(0, command.native_name)
command.names = tuple(names)

View File

@ -57,7 +57,7 @@ class StandardCommonCommands(CommandContainer):
self.chat_buttons_set_visible(new_status)
@command(overlap=True)
@doc(_("Show help on a given command or a list of available commands if -(-a)ll is given"))
@doc(_("Show help on a given command or a list of available commands if -a is given"))
def help(self, command=None, all=False):
if command:
command = self.get_command(command)

View File

@ -205,7 +205,7 @@ def adapt_arguments(command, arguments, args, opts):
# The second stage of transforming options to an associatable state.
# Expanding short, one-letter options to a verbose ones, if
# corresponding optin has been given.
if command.expand_short:
if command.expand:
expanded = []
for spec_key, spec_value in norm_kwargs.iteritems():
letter = spec_key[0] if len(spec_key) > 1 else None