blob: 667f16702638615a1c071f11f52a96a773102f67 [file] [log] [blame]
Jason M. Bills684bb4b2020-09-11 13:19:43 -07001#!/usr/bin/python3
2
3import argparse
4import json
5import re
6
7
8parser = argparse.ArgumentParser()
9parser.add_argument('-b', '--base', default=None, required=True)
10parser.add_argument('-f', '--file', default=None, required=True)
11args = parser.parse_args()
12
13with open(args.file) as error_file:
14 error_data = error_file.readlines()
15
16 with open(args.base) as base_file:
17 base_json = json.load(base_file)
18 for message_name, message_data in base_json['Messages'].items():
19 message_id = base_json['RegistryPrefix'] + '.' + \
20 base_json['RegistryVersion'] + '.' + message_name
21 message_found = False
22 index = 0
23 for i, error in enumerate(error_data):
24 if message_id in error:
25 message_found = True
26 index = i
27 break
28 if not message_found:
29 print("{} not found".format(message_id))
30 continue
31
32 error_info = error_data[index:index + 15]
33 error_str = " ".join(error_info)
34 error_str = re.sub(
35 'std::to_string\(arg(\d+)\)',
36 'arg\\1',
37 error_str)
38 error_str = re.sub('"\n\s*"', '', error_str, re.MULTILINE)
39 error_str = re.sub(
40 '"\s*\+\s*arg(\d+)\s*\+\n?\s*"',
41 '%\\1',
42 error_str,
43 re.MULTILINE)
44 if message_data['Message'] not in error_str:
45 print(
46 "{}: error in Message: {}".format(
47 message_id,
48 message_data['Message']))
49 print(error_str)
50
51 if message_data['MessageSeverity'] not in error_str:
52 print("{}: error in MessageSeverity: {}".format(
53 message_id, message_data['MessageSeverity']))
54 print(error_str)
55
56 if message_data['Resolution'] not in error_str:
57 print(
58 "{}: error in Resolution: {}".format(
59 message_id,
60 message_data['Resolution']))
61 print(error_str)