-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_unit_data_file_from_diff.py
More file actions
32 lines (28 loc) · 1.08 KB
/
Copy pathupdate_unit_data_file_from_diff.py
File metadata and controls
32 lines (28 loc) · 1.08 KB
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
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
"""
Update comic files using new files and old files generated by generate_comic_files.py
This script writes to local_files/new_comic_files.json
"""
import json
import os
file_name = "characters_wikidata.json"
with open(
os.path.join("local_files", "new_unit_data_files.json"), "w", encoding="utf-8"
) as fo:
new_json_data = {}
assert os.path.exists(os.path.join("tracking_files", file_name))
new_data = json.load(open(os.path.join("tracking_files", file_name)))
if os.path.exists(os.path.join("local_files", "old_" + file_name)):
old_data = json.load(open(os.path.join("local_files", "old_" + file_name)))
for k, v in new_data.items():
if k not in old_data:
new_json_data[k] = v
else:
different = False
assert type(v) is dict and type(old_data[k]) is dict
if v != old_data[k]:
new_json_data[k] = v
else:
new_json_data.update(new_data)
json.dump(new_json_data, fo, ensure_ascii=False, indent=4)