VirtualMailManager/cli/subcommands.py
branchv0.7.x
changeset 657 6515e3b88dec
parent 656 4bbca60e0ba4
child 665 33d15936b53a
equal deleted inserted replaced
656:4bbca60e0ba4 657:6515e3b88dec
   324             info['quota limit/user'] = q_limit % info
   324             info['quota limit/user'] = q_limit % info
   325             _print_info(ctx, info, _('Domain'))
   325             _print_info(ctx, info, _('Domain'))
   326         else:
   326         else:
   327             info[0]['bytes'] = human_size(info[0]['bytes'])
   327             info[0]['bytes'] = human_size(info[0]['bytes'])
   328             info[0]['messages'] = locale.format('%d', info[0]['messages'],
   328             info[0]['messages'] = locale.format('%d', info[0]['messages'],
   329                                                 True).decode(ENCODING,
   329                                                 True)
   330                                                              'replace')
       
   331             info[0]['quota limit/user'] = q_limit % info[0]
   330             info[0]['quota limit/user'] = q_limit % info[0]
   332             _print_info(ctx, info[0], _('Domain'))
   331             _print_info(ctx, info[0], _('Domain'))
   333             if details == 'accounts':
   332             if details == 'accounts':
   334                 _print_list(info[1], _('accounts'))
   333                 _print_list(info[1], _('accounts'))
   335             elif details == 'aliasdomains':
   334             elif details == 'aliasdomains':
   995         else:
   994         else:
   996             for domain in alist:
   995             for domain in alist:
   997                 if not domain.startswith('xn--'):
   996                 if not domain.startswith('xn--'):
   998                     w_std('\t%s' % domain)
   997                     w_std('\t%s' % domain)
   999                 else:
   998                 else:
  1000                     w_std('\t%s (%s)' % (domain, domain.decode('idna')))
   999                     w_std('\t%s (%s)' % (domain,
       
  1000                                         domain.encode('utf-8').decode('idna')))
  1001         print()
  1001         print()
  1002     else:
  1002     else:
  1003         w_std(_('\tNone'), '')
  1003         w_std(_('\tNone'), '')
  1004 
  1004 
  1005 
  1005 
  1030 
  1030 
  1031 
  1031 
  1032 def _format_domain(domain, main=True):
  1032 def _format_domain(domain, main=True):
  1033     """format (prefix/convert) the domain name."""
  1033     """format (prefix/convert) the domain name."""
  1034     if domain.startswith('xn--'):
  1034     if domain.startswith('xn--'):
  1035         domain = '%s (%s)' % (domain, domain.decode('idna'))
  1035         domain = '%s (%s)' % (domain, domain.encode('utf-8').decode('idna'))
  1036     if main:
  1036     if main:
  1037         return '\t[+] %s' % domain
  1037         return '\t[+] %s' % domain
  1038     return '\t[-]     %s' % domain
  1038     return '\t[-]     %s' % domain
  1039 
  1039 
  1040 
  1040 
  1100 def _print_aliasdomain_info(info):
  1100 def _print_aliasdomain_info(info):
  1101     """Print alias domain information."""
  1101     """Print alias domain information."""
  1102     title = _('Alias domain information')
  1102     title = _('Alias domain information')
  1103     for key in ('alias', 'domain'):
  1103     for key in ('alias', 'domain'):
  1104         if info[key].startswith('xn--'):
  1104         if info[key].startswith('xn--'):
  1105             info[key] = '%s (%s)' % (info[key], info[key].decode('idna'))
  1105             info[key] = '%s (%s)' % (info[key],
       
  1106                                      info[key].encode(ENCODING).decode('idna'))
  1106     w_std(title, '-' * len(title),
  1107     w_std(title, '-' * len(title),
  1107           _('\tThe alias domain %(alias)s belongs to:\n\t    * %(domain)s') %
  1108           _('\tThe alias domain %(alias)s belongs to:\n\t    * %(domain)s') %
  1108           info, '')
  1109           info, '')
  1109 
  1110 
  1110 del _
  1111 del _