# HG changeset patch # User Pascal Volk # Date 1298817304 0 # Node ID d4a34124850028b2c806efc8652c6a970a568af7 # Parent 241b192bfcc810ce43e11e268395effe2f4cd24b VMM/cli/subcommands: Added function update_cmd_map(). So the items will be added to the cmd_map when gettext's _() has been installed -> translatable subcommand descriptions. diff -r 241b192bfcc8 -r d4a341248500 VirtualMailManager/cli/main.py --- a/VirtualMailManager/cli/main.py Thu Feb 24 22:15:10 2011 +0000 +++ b/VirtualMailManager/cli/main.py Sun Feb 27 14:35:04 2011 +0000 @@ -16,7 +16,8 @@ from VirtualMailManager.cli.handler import CliHandler from VirtualMailManager.constants import DATABASE_ERROR, EX_MISSING_ARGS, \ EX_SUCCESS, EX_UNKNOWN_COMMAND, EX_USER_INTERRUPT, INVALID_ARGUMENT -from VirtualMailManager.cli.subcommands import RunContext, cmd_map, usage +from VirtualMailManager.cli.subcommands import RunContext, cmd_map, \ + update_cmd_map, usage _ = lambda msg: msg @@ -35,6 +36,7 @@ def run(argv): + update_cmd_map() if len(argv) < 2: usage(EX_MISSING_ARGS, _(u"You must specify a subcommand at least.")) diff -r 241b192bfcc8 -r d4a341248500 VirtualMailManager/cli/subcommands.py --- a/VirtualMailManager/cli/subcommands.py Thu Feb 24 22:15:10 2011 +0000 +++ b/VirtualMailManager/cli/subcommands.py Sun Feb 27 14:35:04 2011 +0000 @@ -36,6 +36,7 @@ _ = lambda msg: msg txt_wrpr = TextWrapper(width=get_winsize()[1] - 1) +cmd_map = {} class Command(object): @@ -626,15 +627,18 @@ __copyright__, prog, _(u'is free software and comes with ABSOLUTELY NO WARRANTY.'))) -cmd = Command -cmd_map = { # {{{ + +def update_cmd_map(): + """Update the cmd_map, after gettext's _ was installed.""" + cmd = Command + cmd_map.update({ # Account commands 'getuser': cmd('getuser', 'gu', get_user, _(u'uid'), _(u'get the address of the user with the given UID')), 'useradd': cmd('useradd', 'ua', user_add, _(u'address [password]'), _(u'create a new e-mail user with the given address')), 'userdelete': cmd('userdelete', 'ud', user_delete, - _(u'address') + ' [force]', + _(u'address') + ' [force]', _(u'delete the specified user')), 'userdisable': cmd('userdisable', 'u0', user_disable, _(u'address [service ...]'), @@ -714,7 +718,7 @@ _(u'show a help overview or help for the given subcommand')), 'version': cmd('version', 'v', version, '', _(u'show version and copyright information')), -} # }}} + }) def _get_order(ctx):