VMM/cli/subcommands: Use the common output formatting in list_pwschemes(). v0.6.x
authorPascal Volk <neverseen@users.sourceforge.net>
Tue, 08 Nov 2011 23:25:30 +0000
branchv0.6.x
changeset 471 5d0114f7bb99
parent 470 807ad4df0774
child 472 8f59a2f539e7
VMM/cli/subcommands: Use the common output formatting in list_pwschemes().
VirtualMailManager/cli/subcommands.py
--- a/VirtualMailManager/cli/subcommands.py	Tue Nov 08 21:31:30 2011 +0000
+++ b/VirtualMailManager/cli/subcommands.py	Tue Nov 08 23:25:30 2011 +0000
@@ -427,21 +427,21 @@
 
 def list_pwschemes(ctx_unused):
     """Prints all usable password schemes and password encoding suffixes."""
+    # TODO: Remove trailing colons from keys.
+    # For now it is to late, the translators has stared their work
     keys = (_(u'Usable password schemes:'), _(u'Usable encoding suffixes:'))
     old_ii, old_si = txt_wrpr.initial_indent, txt_wrpr.subsequent_indent
-    txt_wrpr.initial_indent = ''
-    indent = 0
+    txt_wrpr.initial_indent = txt_wrpr.subsequent_indent = '\t'
+    txt_wrpr.width = txt_wrpr.width - 8
 
-    for key in keys:
-        k_len = len(key)
-        if k_len > indent:
-            indent = k_len
-    txt_wrpr.subsequent_indent = (indent + 1) * ' '
-    fmt = '%%-%us %%s' % indent
     for key, value in zip(keys, list_schemes()):
-        w_std('\n'.join(txt_wrpr.wrap(fmt % (key, ' '.join(value)))))
+        if key.endswith(':'):  # who knows … (see TODO above)
+            key = key.rpartition(':')[0]
+        w_std(key, len(key) * '-')
+        w_std('\n'.join(txt_wrpr.wrap(' '.join(value))), '')
 
     txt_wrpr.initial_indent, txt_wrpr.subsequent_indent = old_ii, old_si
+    txt_wrpr.width = txt_wrpr.width + 8
 
 
 def relocated_add(ctx):