Parse single digit sizes

Closes: #946
This commit is contained in:
Jochen Sprickerhof 2021-11-27 21:21:09 +01:00
parent cd69692424
commit a5deaa80d8
2 changed files with 2 additions and 1 deletions

View file

@ -476,7 +476,7 @@ def parse_human_readable_size(size):
raise ValueError(_('Could not parse size "{size}", wrong type "{type}"')
.format(size=size, type=type(size)))
s = size.lower().replace(' ', '')
m = re.match(r'^(?P<value>[0-9][0-9.]+) *(?P<unit>' + r'|'.join(units.keys()) + r')$', s)
m = re.match(r'^(?P<value>[0-9][0-9.]*) *(?P<unit>' + r'|'.join(units.keys()) + r')$', s)
if not m:
raise ValueError(_('Not a valid size definition: "{}"').format(size))
return int(float(m.group("value")) * units[m.group("unit")])