Store and check read edit entry ids

This commit is contained in:
Hans5958 2022-04-09 21:42:05 +07:00
parent 1e1c007d31
commit 6faec6f11d
2 changed files with 18 additions and 5 deletions

View file

@ -8,13 +8,14 @@
out_ids = []
out_dupe_ids = []
out_edited_added_ids = []
atlas_ids = []
with open('temp_atlas.json', 'r', encoding='utf-8') as out_file:
out_json = json.loads(out_file)
out_json = json.loads(out_file.read())
with open('../atlas.json', 'r', encoding='utf-8') as atlas_file:
atlas_json = json.loads(atlas_file)
with open('../web/atlas.json', 'r', encoding='utf-8') as atlas_file:
atlas_json = json.loads(atlas_file.read())
for entry in atlas_json:
atlas_ids.append(entry['id'])
@ -32,10 +33,17 @@
if ('edit' in entry and entry['edit']) or entry['id'] in out_ids:
index = next((i for i, item in enumerate(atlas_json) if item["id"] == entry['id']), None)
if 'edit' in entry:
out_edited_added_ids.append(entry['edit'])
del entry['edit']
atlas_json[index] = entry
else:
atlas_json.append(entry)
with open('../atlas.json', 'w', encoding='utf-8') as atlas_file:
atlas_file.write(per_line_entries(atlas_json))
print('Writing...')
with open('../web/atlas.json', 'w', encoding='utf-8') as atlas_file:
atlas_file.write(per_line_entries(atlas_json))
with open('../data/edit-ids.txt', 'a', encoding='utf-8') as edit_ids_file:
edit_ids_file.write('\n'.join(out_edited_added_ids) + '\n')
print('All done.')

View file

@ -36,6 +36,11 @@
for id in [x.strip() for x in edit_ids_file.readlines()]:
existing_ids.append(id)
with open('../data/edit-ids.txt', 'r') as edit_ids_file:
for id in [x.strip() for x in edit_ids_file.readlines()]:
existing_ids.append(id)
def set_flair(submission, flair):
if has_write_access and submission.link_flair_text != flair:
flair_choices = submission.flair.choices()