Pythonify and fix reported line number

Use enumerate to give the line number and use the correct offset to
actually calculate it.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
Paul Elliott 2021-03-18 18:07:46 +00:00
parent b05a59a550
commit d75773e941

View File

@ -219,14 +219,12 @@ class ChangeLog:
category.name.decode('utf8'))
body_split = category.body.splitlines()
line_number = 1
for line in body_split:
for line_number, line in enumerate(body_split, 1):
if len(line) > MAX_LINE_LENGTH:
raise InputFormatError(filename,
line_offset + category.title_line + line_number,
category.body_line + line_number,
'Line is longer than allowed: Length {} (Max {})',
len(line), MAX_LINE_LENGTH)
line_number += 1
self.categories[category.name] += category.body