-
Notifications
You must be signed in to change notification settings - Fork 2
/
TilChangedReporter.py
69 lines (53 loc) · 1.98 KB
/
TilChangedReporter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import json
import os
import tkinter.filedialog as ask_file
older_data = {}
newer_data = {}
with open(ask_file.askopenfilename(
title = 'Choose an older structure size data file.',
filetypes = [('JSON','*.json'),('All files','*')],
initialdir = os.getcwd()), 'r') as file:
older_data = json.load(file)
with open(ask_file.askopenfilename(
title = 'Choose an newer structure size data file.',
filetypes = [('JSON','*.json'),('All files','*')],
initialdir = os.getcwd()), 'r') as file:
newer_data = json.load(file)
bds_data = None
if os.path.exists('originalData.json'):
with open('originalData.json') as file:
bds_data = json.load(file)
changed_types = {}
for type_name in newer_data:
if type_name not in older_data:
continue
newer = newer_data[type_name]['final_guessed_size']
older = older_data[type_name]['final_guessed_size']
if newer != older and newer != 0 and older != 0:
changed_types[type_name] = {
'after': newer,
'before': older,
'delta': newer - older
}
marked_to_delete = set()
if bds_data:
for type_name in changed_types:
if type_name not in bds_data['classes']:
continue
parents = bds_data['classes'][type_name]['parent_types'] if 'parent_types' in bds_data['classes'][type_name] else []
for parent in parents:
if parent in changed_types and changed_types[parent]['delta'] == changed_types[type_name]['delta']:
marked_to_delete.add(type_name)
for type_name in marked_to_delete:
changed_types.pop(type_name)
result = """#### Changed structure(s):
Type Name | Before | After | Delta
-|-|-|-
"""
for type_name in changed_types:
this = changed_types[type_name]
m = this['after'] - this['before']
result += '`%s` | %d | %d | %s\n' % (type_name, this['before'], this['after'], '+' + str(m) if m > 0 else m)
with open('TilChanges.md', 'w') as file:
file.write(result)
print('All works done.')