check-os-release.py compatible with Python < 3.8

The ":=" operator was only added in Python 3.8 so splitting the line with it into two makes check-os-release.py actually fulfill its claim of working with any python version.
This commit is contained in:
David Jaša 2022-08-23 23:58:09 +02:00 committed by Yu Watanabe
parent 1afe3d712e
commit ce0a056abc

View File

@ -17,7 +17,8 @@ def read_os_release():
line = line.rstrip()
if not line or line.startswith('#'):
continue
if m := re.match(r'([A-Z][A-Z_0-9]+)=(.*)', line):
m = re.match(r'([A-Z][A-Z_0-9]+)=(.*)', line)
if m:
name, val = m.groups()
if val and val[0] in '"\'':
val = ast.literal_eval(val)