VirtualMailManager/cli/subcommands.py
branchv0.6.x
changeset 447 c31d604e26d3
parent 446 18b75e6a39d5
child 448 45c917e6a386
equal deleted inserted replaced
446:18b75e6a39d5 447:c31d604e26d3
   740 def _get_order(ctx):
   740 def _get_order(ctx):
   741     """returns a tuple with (key, 1||0) tuples. Used by functions, which
   741     """returns a tuple with (key, 1||0) tuples. Used by functions, which
   742     get a dict from the handler."""
   742     get a dict from the handler."""
   743     order = ()
   743     order = ()
   744     if ctx.scmd == 'domaininfo':
   744     if ctx.scmd == 'domaininfo':
   745         order = ((u'domainname', 0), (u'gid', 1), (u'transport', 0),
   745         order = ((u'domain name', 0), (u'gid', 1), (u'domain directory', 0),
   746                  (u'domaindir', 0), (u'quota limit', 0), (u'aliasdomains', 0),
   746                  (u'quota limit', 0), (u'active services', 0),
   747                  (u'accounts', 0), (u'aliases', 0), (u'relocated', 0))
   747                  (u'transport', 0), (u'alias domains', 0), (u'accounts', 0),
       
   748                  (u'aliases', 0), (u'relocated', 0))
   748     elif ctx.scmd == 'userinfo':
   749     elif ctx.scmd == 'userinfo':
   749         dc12 = ctx.cget('misc.dovecot_version') >= 0x10200b02
       
   750         sieve = (u'managesieve', u'sieve')[dc12]
       
   751         if ctx.argc == 4 and ctx.args[3] != u'aliases' or \
   750         if ctx.argc == 4 and ctx.args[3] != u'aliases' or \
   752            ctx.cget('account.disk_usage'):
   751            ctx.cget('account.disk_usage'):
   753             order = ((u'address', 0), (u'name', 0), (u'uid', 1), (u'gid', 1),
   752             order = ((u'address', 0), (u'name', 0), (u'uid', 1), (u'gid', 1),
   754                      (u'home', 0), (u'mail_location', 0),
   753                      (u'home', 0), (u'mail_location', 0),
   755                      (u'quota storage', 0), (u'quota messages', 0),
   754                      (u'quota storage', 0), (u'quota messages', 0),
   756                      (u'disk usage', 0), (u'transport', 0), (u'smtp', 1),
   755                      (u'disk usage', 0), (u'transport', 0), (u'smtp', 1),
   757                      (u'pop3', 1), (u'imap', 1), (sieve, 1))
   756                      (u'pop3', 1), (u'imap', 1), (u'sieve', 1))
   758         else:
   757         else:
   759             order = ((u'address', 0), (u'name', 0), (u'uid', 1), (u'gid', 1),
   758             order = ((u'address', 0), (u'name', 0), (u'uid', 1), (u'gid', 1),
   760                      (u'home', 0), (u'mail_location', 0),
   759                      (u'home', 0), (u'mail_location', 0),
   761                      (u'quota storage', 0), (u'quota messages', 0),
   760                      (u'quota storage', 0), (u'quota messages', 0),
   762                      (u'transport', 0), (u'smtp', 1), (u'pop3', 1),
   761                      (u'transport', 0), (u'smtp', 1), (u'pop3', 1),
   763                      (u'imap', 1), (sieve, 1))
   762                      (u'imap', 1), (u'sieve', 1))
   764     elif ctx.scmd == 'getuser':
   763     elif ctx.scmd == 'getuser':
   765         order = ((u'uid', 1), (u'gid', 1), (u'address', 0))
   764         order = ((u'uid', 1), (u'gid', 1), (u'address', 0))
   766     return order
   765     return order
   767 
   766 
   768 
   767 
   790     # TP: used in e.g. 'Domain information' or 'Account information'
   789     # TP: used in e.g. 'Domain information' or 'Account information'
   791     msg = u'%s %s' % (title, _(u'information'))
   790     msg = u'%s %s' % (title, _(u'information'))
   792     w_std(msg, u'-' * len(msg))
   791     w_std(msg, u'-' * len(msg))
   793     for key, upper in _get_order(ctx):
   792     for key, upper in _get_order(ctx):
   794         if upper:
   793         if upper:
   795             w_std(u'\t%s: %s' % (key.upper().ljust(15, u'.'), info[key]))
   794             w_std(u'\t%s: %s' % (key.upper().ljust(17, u'.'), info[key]))
   796         else:
   795         else:
   797             w_std(u'\t%s: %s' % (key.title().ljust(15, u'.'), info[key]))
   796             w_std(u'\t%s: %s' % (key.title().ljust(17, u'.'), info[key]))
   798     print
   797     print
   799 
   798 
   800 
   799 
   801 def _print_list(alist, title):
   800 def _print_list(alist, title):
   802     """Print a list."""
   801     """Print a list."""