Add util.pretty_quantity() convenience function

This commit is contained in:
Lance Edgar 2016-12-10 09:04:47 -06:00
parent 9884772882
commit ad98038239

View file

@ -127,6 +127,18 @@ def prettify(text):
return ' '.join([x.capitalize() for x in words]) return ' '.join([x.capitalize() for x in words])
def pretty_quantity(value):
"""
Return a "pretty" version of the given value, as string. This is meant primarily
for use with things like order quantities, so that e.g. 1.0000 => 1
"""
if value is None:
return ''
if int(value) == value:
return unicode(int(value))
return unicode(value)
def progress_loop(func, items, factory, *args, **kwargs): def progress_loop(func, items, factory, *args, **kwargs):
""" """
This will iterate over ``items`` and call ``func`` for each. If a progress This will iterate over ``items`` and call ``func`` for each. If a progress