mirror of
https://github.com/placeAtlas/atlas.git
synced 2025-01-19 05:21:57 +01:00
Revert "Removed unused contributors field from JSON"
This reverts commit 5deedbdea0
.
This commit is contained in:
parent
56f704caeb
commit
7f735f9abc
5 changed files with 7979 additions and 7931 deletions
|
@ -2,8 +2,11 @@
|
|||
|
||||
import re
|
||||
import json
|
||||
import math
|
||||
import traceback
|
||||
|
||||
from calculate_center import polylabel
|
||||
|
||||
"""
|
||||
Examples:
|
||||
1. - /r/place
|
||||
|
@ -260,6 +263,11 @@ def remove_empty_and_similar(entry: dict):
|
|||
entry["links"][key] = [x for x in entry["links"][key] if x and x.lower() in small]
|
||||
if len(entry["links"][key]) == 0: del entry["links"][key]
|
||||
|
||||
if "contributors" in entry:
|
||||
|
||||
if len(entry["contributors"]) == 0:
|
||||
del entry["contributors"]
|
||||
|
||||
return entry
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
import praw
|
||||
import json
|
||||
from formatter import per_line_entries
|
||||
import time
|
||||
import re
|
||||
import os
|
||||
import traceback
|
||||
from formatter import format_all, per_line_entries
|
||||
|
||||
out_ids = []
|
||||
out_dupe_ids = []
|
||||
|
@ -35,6 +40,11 @@ for entry in out_json:
|
|||
if 'edit' in entry:
|
||||
out_edited_added_ids.append(entry['edit'])
|
||||
del entry['edit']
|
||||
if 'submitted_by' in atlas_json[index]:
|
||||
atlas_json[index]['contributors'] = [ atlas_json[index]['submitted_by'] ]
|
||||
elif not 'contributors' in atlas_json[index]:
|
||||
atlas_json[index]['contributors'] = []
|
||||
entry['contributors'] = atlas_json[index]['contributors'] + list(set(entry['contributors']) - set(atlas_json[index]['contributors']))
|
||||
atlas_json[index] = entry
|
||||
else:
|
||||
print(f"Added {entry['id']}.")
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
Migrator script from old atlas format to remastered atlas format.
|
||||
- center and path: single -> time-specific
|
||||
- website and subreddit: single strings -> links object
|
||||
- submitted_by removed
|
||||
- submitted_by -> contributors
|
||||
"""
|
||||
|
||||
import re
|
||||
|
@ -25,7 +25,8 @@ def migrate_atlas_format(entry: dict):
|
|||
"description": "",
|
||||
"links": {},
|
||||
"path": {},
|
||||
"center": {}
|
||||
"center": {},
|
||||
"contributors": []
|
||||
}
|
||||
|
||||
center = entry['center']
|
||||
|
@ -65,6 +66,10 @@ def migrate_atlas_format(entry: dict):
|
|||
if isinstance(entry["subreddit"], str) and entry["subreddit"]:
|
||||
new_entry['links']['subreddit'] = list(map(lambda x: FS_REGEX.sub(r"\1", x), COMMATIZATION.split(entry['subreddit'])))
|
||||
del entry['subreddit']
|
||||
|
||||
if "submitted_by" in entry:
|
||||
new_entry['contributors'].append(entry['submitted_by'])
|
||||
del entry['submitted_by']
|
||||
|
||||
toreturn = {
|
||||
**new_entry,
|
||||
|
|
|
@ -63,6 +63,17 @@ with open('../data/read-ids.txt', 'r') as edit_ids_file:
|
|||
for id in [x.strip() for x in edit_ids_file.readlines()]:
|
||||
existing_ids.append(id)
|
||||
|
||||
# with open('../web/atlas.json', 'r') as atlas_file:
|
||||
# atlas_raw: list = json.loads(atlas_file)
|
||||
# atlas = {}
|
||||
# atlas_ids = []
|
||||
# for index in atlas_raw:
|
||||
# entry = atlas_raw[index]
|
||||
# id = entry['id']
|
||||
# del entry['id']
|
||||
# atlas[id] = entry
|
||||
# atlas_ids.append(id)
|
||||
|
||||
def set_flair(submission, flair):
|
||||
if has_write_access and submission.link_flair_text != flair:
|
||||
flair_choices = submission.flair.choices()
|
||||
|
@ -109,12 +120,26 @@ for submission in reddit.subreddit('placeAtlas2').new(limit=2000):
|
|||
assert submission_json["id"] != 0, "Edit invalid because ID is tampered, it must not be 0!"
|
||||
|
||||
submission_json_dummy = {"id": submission_json["id"], "edit": submission.id}
|
||||
submission_json["contributors"] = []
|
||||
|
||||
try:
|
||||
if not submission.author.name in submission_json:
|
||||
submission_json["contributors"].append(submission.author.name)
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
else:
|
||||
|
||||
assert submission_json["id"] == 0, "Edit invalid because ID is tampered, it must be 0!"
|
||||
|
||||
submission_json_dummy = {"id": submission.id}
|
||||
submission_json["contributors"] = []
|
||||
|
||||
try:
|
||||
if not submission.author.name in submission_json:
|
||||
submission_json["contributors"].append(submission.author.name)
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
for key in submission_json:
|
||||
if not key in submission_json_dummy:
|
||||
|
|
15856
web/atlas.json
15856
web/atlas.json
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue