MCPcopy Create free account
hub / github.com/FEX-Emu/FEX / main

Function main

Scripts/UpdateInstructionCountJson.py:38–76  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

36 json_file.write("\n")
37
38def main():
39 if sys.version_info[0] < 3:
40 logging.critical ("Python 3 or a more recent version is required.")
41
42 if (len(sys.argv) < 3):
43 logging.critical ("usage: %s <PerformanceTests.json> <NewNumbers.json>" % (sys.argv[0]))
44
45 performance_json_path = sys.argv[1]
46 new_json_numbers = sys.argv[2]
47
48 try:
49 with open(new_json_numbers) as json_file:
50 new_json_numbers_text = json_file.read()
51 except IOError:
52 # If there isn't any new json numbers for this file, then it is safe to skip.
53 return 0
54
55 try:
56 with open(performance_json_path) as json_file:
57 performance_json_text = json_file.read()
58 except IOError:
59 logging.error("IOError!")
60 return 1
61
62 try:
63 performance_json_data = json.loads(performance_json_text)
64 if not isinstance(performance_json_data, dict):
65 raise TypeError('JSON data must be a dict')
66
67 new_json_numbers_data = json.loads(new_json_numbers_text)
68 if not isinstance(new_json_numbers_data, dict):
69 raise TypeError('JSON data must be a dict')
70
71 return update_performance_numbers(performance_json_path, performance_json_data, new_json_numbers_data)
72 except ValueError as ve:
73 logging.error(f'JSON error: {ve}')
74 return 1
75
76 return 0
77
78if __name__ == "__main__":
79# execute only if run as a script

Callers 1

Calls 1

Tested by

no test coverage detected