[PR] #307 from Iris-TheRainbow: Allow lightness values without a % to parse

This commit is contained in:
Azalea 2024-06-27 00:39:35 +08:00 committed by GitHub
commit 7f18d0e042
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -210,12 +210,15 @@ def create_config() -> Config:
return def_lightness
try:
lightness = int(lightness[:-1]) / 100 if lightness.endswith('%') else float(lightness)
if lightness.endswith('%') or int(lightness) > 1:
lightness = int(lightness[:-1]) / 100 if lightness.endswith('%') else int(lightness) / 100
else:
lightness = float(lightness)
assert 0 <= lightness <= 1
return lightness
except Exception:
printc('&cUnable to parse lightness value, please input it as a decimal or percentage (e.g. 0.5 or 50%)')
printc('&cUnable to parse lightness value, please enter a lightness value such as 45%, .45, or 45')
lightness = select_lightness()
_prs = _prs.set_light_dl(lightness, light_dark)