check-style: Start enumerating lines from 1

This way "the line before start" and "the line before end" can be
expressed as "[start|end] - 1", which looks less like using a magic
number.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2733>
This commit is contained in:
Hunor Csomortáni 2022-12-02 14:32:50 +01:00
parent ec17d19c76
commit 1493bf9610

View File

@ -43,13 +43,13 @@ def reformat_chunks(chunks, rewrite):
with open(file) as f:
tmp = tempfile.NamedTemporaryFile()
tmp.write(b'/** *INDENT-OFF* **/\n')
for i, line in enumerate(f):
if i == start - 2:
for i, line in enumerate(f, start=1):
if i == start - 1:
tmp.write(b'/** *INDENT-ON* **/\n')
tmp.write(bytes(line, 'utf-8'))
if i == end - 2:
if i == end - 1:
tmp.write(b'/** *INDENT-OFF* **/\n')
tmp.seek(0)