# HG changeset patch # User Pascal Volk # Date 1298407276 0 # Node ID ae1a8428298cffa8359ede0fbb62f66da838aae1 # Parent e5b3b225bd5b125b7c3cff958af32976f804b432 VMM: Report quota usage/limit/percentage values formatted according to the current LC_ALL setting. diff -r e5b3b225bd5b -r ae1a8428298c VirtualMailManager/cli/subcommands.py --- a/VirtualMailManager/cli/subcommands.py Tue Feb 22 20:12:18 2011 +0000 +++ b/VirtualMailManager/cli/subcommands.py Tue Feb 22 20:41:16 2011 +0000 @@ -257,13 +257,16 @@ else: raise else: - q_limit = u'Storage: %(bytes)s; Messages: %(messages)u' + q_limit = u'Storage: %(bytes)s; Messages: %(messages)s' if not details: info['bytes'] = human_size(info['bytes']) + info['messages'] = locale.format('%d', info['messages'], True) info['quota limit'] = q_limit % info _print_info(ctx, info, _(u'Domain')) else: info[0]['bytes'] = human_size(info[0]['bytes']) + info[0]['messages'] = locale.format('%d', info[0]['messages'], + True) info[0]['quota limit'] = q_limit % info[0] _print_info(ctx, info[0], _(u'Domain')) if details == u'accounts': @@ -751,14 +754,14 @@ } else: q_usage = { - 'used': used, - 'limit': limit, + 'used': locale.format('%d', used, True), + 'limit': locale.format('%d', limit, True), } if limit: - q_usage['percent'] = 100. / limit * used + q_usage['percent'] = locale.format('%6.2f', 100. / limit * used, True) else: - q_usage['percent'] = 0. - return _(u'[%(percent)6.2f%%] %(used)s/%(limit)s') % q_usage + q_usage['percent'] = locale.format('%6.2f', 0, True) + return _(u'[%(percent)s%%] %(used)s/%(limit)s') % q_usage def _print_info(ctx, info, title): diff -r e5b3b225bd5b -r ae1a8428298c VirtualMailManager/common.py --- a/VirtualMailManager/common.py Tue Feb 22 20:12:18 2011 +0000 +++ b/VirtualMailManager/common.py Tue Feb 22 20:41:16 2011 +0000 @@ -8,6 +8,7 @@ Some common functions """ +import locale import os import re import stat @@ -82,9 +83,10 @@ (_(u'MiB'), 1 << 20), (_(u'KiB'), 1 << 10)) for prefix, multiply in prefix_multiply: if size >= multiply: - # TP: e.g.: '%(size).2f %(prefix)s' -> '118.30 MiB' - return _(u'%(size).2f %(prefix)s') % { - 'size': float(size) / multiply, + # TP: e.g.: '%(size)s %(prefix)s' -> '118.30 MiB' + return _(u'%(size)s %(prefix)s') % { + 'size': locale.format('%.2f', float(size) / multiply, + True), 'prefix': prefix}