mirror of
https://github.com/systemd/systemd.git
synced 2024-11-23 18:23:32 +08:00
man: prettify line number handling in python example
This way the 'line_number' variable contains the actual line number as we think of it, instead of adjusting it on output.
This commit is contained in:
parent
75c293f37d
commit
baf60a80b5
@ -13,7 +13,7 @@ def read_os_release():
|
||||
filename = '/usr/lib/os-release'
|
||||
f = open(filename)
|
||||
|
||||
for line_number, line in enumerate(f):
|
||||
for line_number, line in enumerate(f, start=1):
|
||||
line = line.rstrip()
|
||||
if not line or line.startswith('#'):
|
||||
continue
|
||||
@ -23,7 +23,7 @@ def read_os_release():
|
||||
val = ast.literal_eval(val)
|
||||
yield name, val
|
||||
else:
|
||||
print(f'{filename}:{line_number + 1}: bad line {line!r}',
|
||||
print(f'{filename}:{line_number}: bad line {line!r}',
|
||||
file=sys.stderr)
|
||||
|
||||
os_release = dict(read_os_release())
|
||||
|
Loading…
Reference in New Issue
Block a user