mirror of
https://github.com/placeAtlas/atlas.git
synced 2024-06-10 07:19:26 +02:00
commit
0e295fe78e
|
@ -1,9 +1,8 @@
|
|||
import json
|
||||
import os
|
||||
from aformatter import format_all_entries, per_line_entries
|
||||
import scale_back
|
||||
import traceback
|
||||
|
||||
import scale_back
|
||||
from scale_back import ScaleConfig
|
||||
|
||||
out_ids = []
|
||||
|
@ -19,17 +18,6 @@
|
|||
with open('../web/atlas.json', 'r', encoding='utf-8') as atlas_file:
|
||||
atlas_data = json.loads(atlas_file.read())
|
||||
|
||||
# format_all_entries(atlas_data)
|
||||
|
||||
# base_image_path = os.path.join('..', 'web', '_img', 'canvas', 'place30')
|
||||
# ScaleConfig.image1 = os.path.join(base_image_path, '159.png')
|
||||
# scale_back.swap_source_dest('164', '165', os.path.join(base_image_path, '163_159.png'))
|
||||
# scale_back.scale_back_entries(atlas_data)
|
||||
# scale_back.swap_source_dest('165', '166', os.path.join(base_image_path, '164_159.png'))
|
||||
# scale_back.scale_back_entries(atlas_data)
|
||||
# scale_back.swap_source_dest('166', '167', os.path.join(base_image_path, '165_159.png'))
|
||||
# scale_back.scale_back_entries(atlas_data)
|
||||
|
||||
last_id = 0
|
||||
|
||||
for i, entry in enumerate(atlas_data):
|
||||
|
@ -39,11 +27,22 @@
|
|||
last_id = int(id)
|
||||
|
||||
patches_dir = "../data/patches/"
|
||||
permanent_patch_file = "temp-atlas.json"
|
||||
if not os.path.exists(patches_dir):
|
||||
print("Patches folder not found. Exiting.")
|
||||
exit()
|
||||
|
||||
for filename in os.listdir(patches_dir):
|
||||
base_image_path = os.path.join('..', 'web', '_img', 'canvas', 'place30')
|
||||
ScaleConfig.image1 = os.path.join(base_image_path, '159.png')
|
||||
|
||||
filenames = os.listdir(patches_dir)
|
||||
filenames.append(permanent_patch_file)
|
||||
|
||||
for filename in filenames:
|
||||
is_permanent_file = filename == permanent_patch_file
|
||||
if is_permanent_file:
|
||||
f = filename
|
||||
else:
|
||||
f = os.path.join(patches_dir, filename)
|
||||
|
||||
print(f"{filename}: Processing...")
|
||||
|
@ -53,8 +52,20 @@
|
|||
|
||||
try:
|
||||
with open(f, 'r', encoding='utf-8') as entry_file:
|
||||
entry = json.loads(entry_file.read())
|
||||
entries = json.loads(entry_file.read())
|
||||
if not isinstance(entries, list):
|
||||
entries = [entries]
|
||||
|
||||
format_all_entries(entries)
|
||||
|
||||
scale_back.swap_source_dest('164', '165', os.path.join(base_image_path, '163_159.png'))
|
||||
scale_back.scale_back_entries(entries)
|
||||
scale_back.swap_source_dest('165', '166', os.path.join(base_image_path, '164_159.png'))
|
||||
scale_back.scale_back_entries(entries)
|
||||
scale_back.swap_source_dest('166', '167', os.path.join(base_image_path, '165_159.png'))
|
||||
scale_back.scale_back_entries(entries)
|
||||
|
||||
for entry in entries:
|
||||
if '_reddit_id' in entry:
|
||||
reddit_id = entry['_reddit_id']
|
||||
if reddit_id in out_ids:
|
||||
|
@ -75,11 +86,13 @@
|
|||
authors.append(author)
|
||||
del entry['_author']
|
||||
|
||||
if entry['id'] is int and entry['id'] < 1:
|
||||
if isinstance(entry['id'], int) and entry['id'] < 1 or entry['id'] == '0':
|
||||
last_id += 1
|
||||
print(f"{filename}: Entry is new, assigned ID {last_id}")
|
||||
entry['id'] = str(last_id)
|
||||
elif entry['id'] not in out_ids:
|
||||
elif isinstance(entry['id'], int):
|
||||
entry['id'] = str(entry['id'])
|
||||
elif not is_permanent_file and entry['id'] not in out_ids:
|
||||
out_ids.append(entry['id'])
|
||||
|
||||
if entry['id'] in atlas_ids:
|
||||
|
@ -90,6 +103,7 @@
|
|||
print(f"{filename}: Added {entry['id']}.")
|
||||
atlas_data.append(entry)
|
||||
|
||||
if not is_permanent_file:
|
||||
os.remove(f)
|
||||
|
||||
except:
|
||||
|
|
|
@ -254,7 +254,7 @@ window.defaultVariation = defaultVariation
|
|||
let defaultPeriod = variationsConfig[defaultVariation].default
|
||||
window.defaultPeriod = defaultPeriod
|
||||
|
||||
const useNumericalId = true
|
||||
const useNumericalId = false
|
||||
window.useNumericalId = useNumericalId
|
||||
|
||||
console.info(`%cThe 2022 r/place Atlas
|
||||
|
|
|
@ -5559,3 +5559,4 @@ waddleguin
|
|||
GDJosef
|
||||
eri531
|
||||
-Yox-
|
||||
gh:Slymeball
|
||||
|
|
415
web/atlas.json
415
web/atlas.json
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue