Skip to content

Commit

Permalink
Merge pull request #383 from ed-velez/issue_382
Browse files Browse the repository at this point in the history
Allow values without a suffix to be interpreted as bytes
  • Loading branch information
soulen3 authored Nov 6, 2024
2 parents 1f0c53a + 636098a commit 341f9fc
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -567,10 +567,14 @@ def parse_size(units_string):

units = "kKmMgGtTpPeE"

match = re.match(r"^(\d+(?:[.]\d+)?)([%s])$" % units, units_string)
match = re.match(r"^(\d+(?:[.]\d+)?)([%s]?)$" % units, units_string)
if not match:
raise ValueError("Invalid constant size syntax %r" % units_string)
number, unit = match.groups()

if not unit:
return int(float(number))

unit = unit.upper()

exponent = "KMGTPE".find(unit)
Expand Down

0 comments on commit 341f9fc

Please sign in to comment.