VirtualMailManager/cli/subcommands.py
branchv0.6.x
changeset 527 e09139525580
parent 515 09fa019bb330
child 528 4b8c3f51d7da
--- a/VirtualMailManager/cli/subcommands.py	Fri Apr 13 23:09:40 2012 +0200
+++ b/VirtualMailManager/cli/subcommands.py	Fri Apr 13 23:24:12 2012 +0200
@@ -16,7 +16,8 @@
 
 from VirtualMailManager import ENCODING
 from VirtualMailManager.cli import get_winsize, prog, w_err, w_std
-from VirtualMailManager.common import human_size, size_in_bytes, version_str
+from VirtualMailManager.common import human_size, size_in_bytes, \
+     version_str, format_domain_default
 from VirtualMailManager.constants import __copyright__, __date__, \
      __version__, ACCOUNT_EXISTS, ALIAS_EXISTS, ALIASDOMAIN_ISDOMAIN, \
      DOMAIN_ALIAS_EXISTS, INVALID_ARGUMENT, EX_MISSING_ARGS, RELOCATED_EXISTS
@@ -572,15 +573,17 @@
     else:
         if details in (None, 'du'):
             info['quota storage'] = _format_quota_usage(info['ql_bytes'],
-                    info['uq_bytes'], True)
+                    info['uq_bytes'], True, info['ql_domaindefault'])
             info['quota messages'] = _format_quota_usage(info['ql_messages'],
-                    info['uq_messages'])
+                    info['uq_messages'], domaindefault=info['ql_domaindefault'])
             _print_info(ctx, info, _(u'Account'))
         else:
             info[0]['quota storage'] = _format_quota_usage(info[0]['ql_bytes'],
-                    info[0]['uq_bytes'], True)
-            info[0]['quota messages'] = _format_quota_usage(
-                    info[0]['ql_messages'], info[0]['uq_messages'])
+                    info[0]['uq_bytes'], True, info[0]['ql_domaindefault'])
+            info[0]['quota messages'] = \
+                _format_quota_usage(info[0]['ql_messages'],
+                                    info[0]['uq_messages'],
+                                    domaindefault=info[0]['ql_domaindefault'])
             _print_info(ctx, info[0], _(u'Account'))
             _print_list(info[1], _(u'alias addresses'))
 
@@ -830,7 +833,7 @@
     return order
 
 
-def _format_quota_usage(limit, used, human=False):
+def _format_quota_usage(limit, used, human=False, domaindefault=False):
     """Put quota's limit / usage / percentage in a formatted string."""
     if human:
         q_usage = {
@@ -846,7 +849,8 @@
         q_usage['percent'] = locale.format('%6.2f', 100. / limit * used, True)
     else:
         q_usage['percent'] = locale.format('%6.2f', 0, True)
-    return _(u'[%(percent)s%%] %(used)s/%(limit)s') % q_usage
+    fmt = format_domain_default if domaindefault else lambda s: s
+    return fmt(_(u'[%(percent)s%%] %(used)s/%(limit)s') % q_usage)
 
 
 def _print_info(ctx, info, title):