Add util.pretty_quantity()
convenience function
This commit is contained in:
parent
9884772882
commit
ad98038239
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue