remove 'unit' argument from 'util.format_value()'
This commit is contained in:
@@ -294,15 +294,15 @@ class TerminalOutput(NullOutput):
|
||||
|
||||
def progress(self, bytes_total, bytes_downloaded, bytes_per_second):
|
||||
if bytes_total is None:
|
||||
print("\r {:>8} {:>10} \r".format(
|
||||
util.format_value(bytes_downloaded, "B"),
|
||||
util.format_value(bytes_per_second, "B/s"),
|
||||
print("\r {:>7}B {:>7}B/s \r".format(
|
||||
util.format_value(bytes_downloaded),
|
||||
util.format_value(bytes_per_second),
|
||||
), end="")
|
||||
else:
|
||||
print("\r{:>3}% {:>8} {:>10} \r".format(
|
||||
print("\r{:>3}% {:>7}B {:>7}B/s \r".format(
|
||||
bytes_downloaded * 100 // bytes_total,
|
||||
util.format_value(bytes_downloaded, "B"),
|
||||
util.format_value(bytes_per_second, "B/s"),
|
||||
util.format_value(bytes_downloaded),
|
||||
util.format_value(bytes_per_second),
|
||||
), end="")
|
||||
|
||||
|
||||
|
||||
@@ -91,15 +91,15 @@ def generate_token(size=16):
|
||||
return binascii.hexlify(data).decode()
|
||||
|
||||
|
||||
def format_value(value, unit="B", suffixes="kMGTPEZY"):
|
||||
def format_value(value, suffixes="kMGTPEZY"):
|
||||
value = format(value)
|
||||
value_len = len(value)
|
||||
index = value_len - 4
|
||||
if index >= 0:
|
||||
offset = (value_len - 1) % 3 + 1
|
||||
return (value[:offset] + "." + value[offset:offset+2] +
|
||||
suffixes[index // 3] + unit)
|
||||
return value + unit
|
||||
suffixes[index // 3])
|
||||
return value
|
||||
|
||||
|
||||
def combine_dict(a, b):
|
||||
|
||||
Reference in New Issue
Block a user