Skip to content

Commit

Permalink
[SQUASHME] compare schema version as tuples
Browse files Browse the repository at this point in the history
  • Loading branch information
fernflower committed May 18, 2021
1 parent d5e778d commit 80c8a72
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions leapp/utils/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ def importance(message):


def generate_report_file(messages_to_report, context, path, report_schema):
# NOTE(ivasilev) Int conversion should not break as only specific formats of report_schema versions are allowed
report_schema_tuple = tuple([int(x) for x in report_schema.split('.')])
if path.endswith(".txt"):
with open(path, 'w') as f:
for message in sorted(messages_to_report, key=importance):
Expand All @@ -100,14 +102,14 @@ def generate_report_file(messages_to_report, context, path, report_schema):
remediation = Remediation.from_dict(message.get('detail', {}))
if remediation:
f.write('Remediation: {}\n'.format(remediation))
if not report_schema or report_schema > '1.0.0':
if report_schema_tuple > (1, 0, 0):
# report-schema 1.0.0 doesn't have a stable report key
f.write('Key: {}\n'.format(message['key']))
f.write('-' * 40 + '\n')
elif path.endswith(".json"):
with open(path, 'w') as f:
# Here all possible convertions will take place
if report_schema < '1.1.0':
if report_schema_tuple < (1, 1, 0):
# report-schema 1.0.0 doesn't have a stable report key
# copy list of messages here not to mess the initial structure for possible further invocations
messages_to_report = list(messages_to_report)
Expand Down

0 comments on commit 80c8a72

Please sign in to comment.