Implement per-entry patches 4

Continue when patch errors instead of ending the whole process
This commit is contained in:
Hans5958 2023-06-16 00:03:33 +07:00
parent da4efb6c60
commit 4cbee4fee6

View file

@ -2,6 +2,7 @@
import os
from aformatter import format_all_entries, per_line_entries
import scale_back
import traceback
from scale_back import ScaleConfig
@ -50,6 +51,7 @@
if not os.path.isfile(f) or not f.endswith('json'):
continue
try:
with open(f, 'r', encoding='utf-8') as entry_file:
entry = json.loads(entry_file.read())
@ -78,7 +80,6 @@
else:
out_ids.append(entry['id'])
if entry['id'] in atlas_ids:
index = atlas_ids[entry['id']]
print(f"{filename}: Edited {atlas_data[index]['id']}.")
@ -89,6 +90,10 @@
os.remove(f)
except:
print(f"{filename}: Something went wrong; patch couldn't be implemented. Skipping.")
traceback.print_exc()
print('Writing...')
with open('../web/atlas.json', 'w', encoding='utf-8') as atlas_file:
per_line_entries(atlas_data, atlas_file)