Flake fix

Signed-off-by: Stephen L. <lrq3000@gmail.com>
This commit is contained in:
Stephen L 2015-07-12 06:44:04 +02:00
parent 1305eacbee
commit 05dc6d5011
1 changed files with 16 additions and 9 deletions

View File

@ -21,12 +21,13 @@ def format_sizeof(num, suffix='bytes'):
""" """
Readable size format, courtesy of Sridhar Ratnakumar Readable size format, courtesy of Sridhar Ratnakumar
""" """
for unit in ['','K','M','G','T','P','E','Z']: for unit in ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z']:
if abs(num) < 1000.0: if abs(num) < 1000.0:
return "%3.1f%s%s" % (num, unit, suffix) return "%3.1f%s%s" % (num, unit, suffix)
num /= 1000.0 num /= 1000.0
return "%.1f%s%s" % (num, 'Y', suffix) return "%.1f%s%s" % (num, 'Y', suffix)
def format_interval(t): def format_interval(t):
mins, s = divmod(int(t), 60) mins, s = divmod(int(t), 60)
h, m = divmod(mins, 60) h, m = divmod(mins, 60)
@ -36,7 +37,8 @@ def format_interval(t):
return '{0:02d}:{1:02d}'.format(m, s) return '{0:02d}:{1:02d}'.format(m, s)
def format_meter(n, total, elapsed, ncols=None, prefix='', unit=None, unit_scale=False, ascii=False): def format_meter(n, total, elapsed, ncols=None, prefix='', \
unit=None, unit_scale=False, ascii=False):
""" """
Return a string-based progress bar given some parameters Return a string-based progress bar given some parameters
@ -59,9 +61,10 @@ def format_meter(n, total, elapsed, ncols=None, prefix='', unit=None, unit_scale
String that will be used to define the unit of each iteration. String that will be used to define the unit of each iteration.
[default: "it"] [default: "it"]
unit_scale : bool, optional unit_scale : bool, optional
If set, the number of iterations will be reduced/scaled automatically If set, the number of iterations will be reduced/scaled
and a metric prefix following the International System of Units standard automatically and a metric prefix following the
will be added (kilo, mega, etc.). [default: False] International System of Units standard will be added
(kilo, mega, etc.). [default: False]
ascii : bool, optional ascii : bool, optional
If not set, use unicode (smooth blocks) to fill the meter If not set, use unicode (smooth blocks) to fill the meter
[default: False]. The fallback is to use ASCII characters (1-9 #). [default: False]. The fallback is to use ASCII characters (1-9 #).
@ -70,7 +73,10 @@ def format_meter(n, total, elapsed, ncols=None, prefix='', unit=None, unit_scale
------- -------
out : Formatted meter and stats, ready to display. out : Formatted meter and stats, ready to display.
""" """
if total and n > total: # in case the total is wrong (n is above the total), then we switch to the mode without showing the total prediction (since ETA would be wrong anyway)
# in case the total is wrong (n is above the total), then we switch to the mode without showing
# the total prediction (since ETA would be wrong anyway)
if total and n > total:
total = None total = None
elapsed_str = format_interval(elapsed) elapsed_str = format_interval(elapsed)
@ -184,9 +190,10 @@ class tqdm(object):
String that will be used to define the unit of each iteration. String that will be used to define the unit of each iteration.
[default: "it"] [default: "it"]
unit_scale : bool, optional unit_scale : bool, optional
If set, the number of iterations will be reduced/scaled automatically If set, the number of iterations will be reduced/scaled
and a metric prefix following the International System of Units standard automatically and a metric prefix following the
will be added (kilo, mega, etc.). [default: False] International System of Units standard will be added
(kilo, mega, etc.). [default: False]
ascii : bool, optional ascii : bool, optional
If not set, use unicode (smooth blocks) to fill the meter If not set, use unicode (smooth blocks) to fill the meter
[default: False]. The fallback is to use ASCII characters (1-9 #). [default: False]. The fallback is to use ASCII characters (1-9 #).