VMM/cli/subcommands: Added function update_cmd_map(). v0.6.x
authorPascal Volk <neverseen@users.sourceforge.net>
Sun, 27 Feb 2011 14:35:04 +0000
branchv0.6.x
changeset 420 d4a341248500
parent 419 241b192bfcc8
child 421 ff2a61e155db
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.
VirtualMailManager/cli/main.py
VirtualMailManager/cli/subcommands.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."))
 
--- 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):