error message improvement

This commit is contained in:
surister 2019-12-21 23:18:34 +01:00
parent 0d81653131
commit fffc60391a

View File

@ -58,16 +58,17 @@ def check_details_tag(file_list):
pass pass
else: else:
if b'<details>' in line and after_detail: if b'<details>' in line and after_detail:
err_message = f'Missing closing detail tag round line {line_number - 1}'
error = True error = True
if b'</details>' in line and not after_detail: if b'</details>' in line and not after_detail:
err_message = f'Missing opening detail tag at line {line_number}' err_message = f'Missing opening detail tag round line {line_number - 1}'
error = True error = True
if b'<details>' in line: if b'<details>' in line:
after_detail = True after_detail = True
if b'</details>' in line and after_detail: if b'</details>' in line and after_detail:
err_message = f'Missing closing detail tag at line {line_number}'
after_detail = False after_detail = False
if error: if error:
@ -85,25 +86,25 @@ def check_summary_tag(file_list):
""" """
after_detail = False after_summary = False
error = False error = False
err_message = '' err_message = ''
for line_number, line in enumerate(file_list): for line_number, line in enumerate(file_list):
if b'<summary>' in line and b'</summary>' in line: if b'<summary>' in line and b'</summary>' in line:
pass pass
else: else:
if b'<summary>' in line and after_detail: if b'<summary>' in line and after_summary:
err_message = f'Missing closing summary tag around line {line_number}'
error = True error = True
if b'</summary>' in line and not after_detail: if b'</summary>' in line and not after_summary:
err_message = f'Missing opening summary tag at line {line_number}' err_message = f'Missing opening summary tag around line {line_number}'
error = True error = True
if b'<summary>' in line: if b'<summary>' in line:
after_detail = True after_summary = True
if b'</summary>' in line and after_detail: if b'</summary>' in line and after_summary:
err_message = f'Missing closing summary tag at line {line_number}' after_summary = False
after_detail = False
if error: if error:
raise Exception(err_message) raise Exception(err_message)