# HG changeset patch # User Pascal Volk # Date 1297425179 0 # Node ID 0a13849243f205d84469e5ef068db63c27229575 # Parent d3a3c615587942afab2969339439df6b8edde42c VMM/common: human_size accept also 0 as size. diff -r d3a3c6155879 -r 0a13849243f2 VirtualMailManager/common.py --- a/VirtualMailManager/common.py Fri Feb 11 02:15:51 2011 +0000 +++ b/VirtualMailManager/common.py Fri Feb 11 11:52:59 2011 +0000 @@ -69,8 +69,10 @@ def human_size(size): """Converts the `size` in bytes in human readable format.""" - if not isinstance(size, (long, int)) or size < 1: - raise TypeError("'size' must be a long or int and greater than 0.") + if not isinstance(size, (long, int)) or size < 0: + raise TypeError("'size' must be a positive long or int.") + if not size: + return '0b' unit_limit = (('T', 1 << 40), ('G', 1 << 30), ('M', 1 << 20), ('k', 1 << 10), ('b', 1)) for unit, limit in unit_limit: