Skip to content

Commit

Permalink
doh: allow empty unit, also strip spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Nov 15, 2023
1 parent b3c2a37 commit 802a6be
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions xpra/scripts/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,7 @@ def parse_with_unit(numtype:str, v, subunit="bps", min_value=250000) -> int | No
r = re.match(r'([0-9\.]*)(.*)', v)
assert r
f = float(r.group(1))
unit = r.group(2).lower()
unit = r.group(2).lower().strip()
if unit.endswith(subunit):
unit = unit[:-len(subunit)] #ie: 10mbps -> 10m
if unit=="k":
Expand All @@ -1216,9 +1216,9 @@ def parse_with_unit(numtype:str, v, subunit="bps", min_value=250000) -> int | No
f *= 1000000
elif unit=="g":
f *= 1000000000
elif unit != "":
pass #no multiplier
elif unit!="b":
elif unit in ("", "b"):
pass # no multiplier
else:
raise ValueError(f"unknown unit {unit!r}")
if min_value is not None:
if f<min_value:
Expand Down

0 comments on commit 802a6be

Please sign in to comment.