overall better handling and usage of exceptions
All checks were successful
bundlewrap/pipeline/head This commit looks good
All checks were successful
bundlewrap/pipeline/head This commit looks good
This commit is contained in:
parent
5d5930265a
commit
f8bbe00d47
21 changed files with 57 additions and 28 deletions
|
@ -9,7 +9,8 @@ import re
|
|||
def to_bytes(size):
|
||||
suffixes = ['', 'K', 'M', 'G', 'T', 'P']
|
||||
number, suffix = re.match(r'([0-9\.]+)([A-Z]?)', size).groups()
|
||||
assert suffix in suffixes, 'Unexpected suffix "{}" in size "{}"'.format(suffix, size)
|
||||
if suffix not in suffixes:
|
||||
print('Unexpected suffix "{}" in size "{}"'.format(suffix, size)
|
||||
return float(number) * 1024**suffixes.index(suffix)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue