overall better handling and usage of exceptions
All checks were successful
bundlewrap/pipeline/head This commit looks good

This commit is contained in:
Franzi 2021-04-02 18:57:13 +02:00
parent 5d5930265a
commit f8bbe00d47
Signed by: kunsi
GPG key ID: 12E3D2136B818350
21 changed files with 57 additions and 28 deletions

View file

@ -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)