diff --git a/tools/formatter.py b/tools/aformatter.py similarity index 100% rename from tools/formatter.py rename to tools/aformatter.py diff --git a/tools/validate_json.py b/tools/ci/validate_json.py similarity index 87% rename from tools/validate_json.py rename to tools/ci/validate_json.py index aa8ba5a2..9f2bcfdf 100644 --- a/tools/validate_json.py +++ b/tools/ci/validate_json.py @@ -3,7 +3,7 @@ import sys import json -path = "./../web/atlas.json" +path = "./../../web/atlas.json" # path override as 1st param: validate_json.py path_to_file.json if (len(sys.argv) > 1): diff --git a/tools/merge_out.py b/tools/merge_out.py index 7d202d84..dc16d768 100644 --- a/tools/merge_out.py +++ b/tools/merge_out.py @@ -1,6 +1,6 @@ import json import os -import formatter +from aformatter import format_all_entries, per_line_entries import scale_back from scale_back import ScaleConfig @@ -10,7 +10,7 @@ with open(merge_source_file, 'r', encoding='UTF-8') as f1: out_json = json.loads(f1.read()) -formatter.format_all_entries(out_json) +format_all_entries.format_all_entries(out_json) base_image_path = os.path.join('..', 'web', '_img', 'canvas', 'place30') ScaleConfig.image1 = os.path.join(base_image_path, '159.png') @@ -60,7 +60,7 @@ print('Writing...') with open('../web/atlas.json', 'w', encoding='utf-8') as atlas_file: - atlas_file.write(formatter.per_line_entries(atlas_json)) + atlas_file.write(per_line_entries(atlas_json)) with open('../data/read-ids.txt', 'a', encoding='utf-8') as read_ids_file: with open('temp-read-ids.txt', 'r+', encoding='utf-8') as read_ids_temp_file: diff --git a/tools/one-off/all-authors.py b/tools/oneoff/all-authors.py similarity index 100% rename from tools/one-off/all-authors.py rename to tools/oneoff/all-authors.py diff --git a/tools/one-off/calculate_center.py b/tools/oneoff/calculate_center.py similarity index 100% rename from tools/one-off/calculate_center.py rename to tools/oneoff/calculate_center.py diff --git a/tools/one-off/migrate_atlas_format.py b/tools/oneoff/migrate_atlas_format.py similarity index 100% rename from tools/one-off/migrate_atlas_format.py rename to tools/oneoff/migrate_atlas_format.py diff --git a/tools/redditflairset.py b/tools/oneoff/redditflairset.py similarity index 73% rename from tools/redditflairset.py rename to tools/oneoff/redditflairset.py index 25da69df..0e15ca9c 100644 --- a/tools/redditflairset.py +++ b/tools/oneoff/redditflairset.py @@ -1,6 +1,25 @@ -# Script to retroactively fix flairs -# Only touches things flaired "New entry" that either fail JSON parsing or are already in the Atlas -# Otherwise, it leaves them untouched +""" +Script to retroactively fix flairs +Only touches things flaired "New entry" that either fail JSON parsing or are already in the Atlas +Otherwise, it leaves them untouched + +Setting up authentication: +1. Head to https://www.reddit.com/prefs/apps +2. Click "are you a developer? create an app..." on the button +3. Enter the name and description +4. Select "script" for the type +5. Enter "redirect uri" as "http://localhost:8080" +6. Create file "credentials" with the format below +┌──────────────────────────────────────────────────────────────────────────────┐ +│ [id] <- Under "personal use script" │ +│ [secret] │ +│ [username] <- For flair access, must be a mod, Don't do this... │ +│ [password] <- ...if you don't know what you are doing. │ +└──────────────────────────────────────────────────────────────────────────────┘ + +Running: +1. Run the script +""" import praw import json @@ -42,7 +61,7 @@ def set_flair(submission, flair): total_all_flairs = 0 rejected_count = 0 processed_count = 0 -#for submission in reddit.subreddit('placeAtlas2').new(limit=1000): +for submission in reddit.subreddit('placeAtlas2').new(limit=1000): #for submission in reddit.subreddit('placeAtlas2').search('flair:"New Entry"',limit=1000,syntax='lucene', sort="top"): #for submission in reddit.subreddit('placeAtlas2').search('flair:"New Entry"',limit=1000,syntax='lucene', sort="comments"): #for submission in reddit.subreddit('placeAtlas2').search('flair:"New Entry"',limit=1000,syntax='lucene', sort="hot"): diff --git a/tools/one-off/users.py b/tools/oneoff/users.py similarity index 100% rename from tools/one-off/users.py rename to tools/oneoff/users.py diff --git a/tools/redditcrawl.py b/tools/redditcrawl.py index d62cdc1c..9f5a4103 100755 --- a/tools/redditcrawl.py +++ b/tools/redditcrawl.py @@ -1,23 +1,23 @@ """ -Auth setup +Setting up authentication: 1. Head to https://www.reddit.com/prefs/apps -2. Click "create another app" -3. Give it a name and description -4. Select "script" -5. Redirect to http://localhost:8080 +2. Click "are you a developer? create an app..." on the button +3. Enter the name and description +4. Select "script" for the type +5. Enter "redirect uri" as "http://localhost:8080" 6. Create file "credentials" with the format below -┌─────────────────────────────────────────────────────┐ -│ [ID] <- Under "personal use script" │ -│ [Secret] │ -│ [Username] <- Must be a mod, don't do this if you │ -│ [Password] <- don't know what you are doing. │ -└─────────────────────────────────────────────────────┘ -7. Run Script +┌──────────────────────────────────────────────────────────────────────────────┐ +│ [id] <- Under "personal use script" │ +│ [secret] │ +│ [username] <- For flair access, must be a mod, Don't do this... │ +│ [password] <- ...if you don't know what you are doing. │ +└──────────────────────────────────────────────────────────────────────────────┘ -Running Script -1. Input the next ID to use -2. Manually resolve errors in temp-atlas-manual.json -3 a. Use merge_out.py, or... +Running: +1. Run the script +2. Input the next ID to use +3. Manually resolve errors in temp-atlas-manual.json +4 a. Use merge_out.py, or... b. a. Copy temp-atlas.json entries into web/_js/atlas.js (mind the edits!) b. Copy temp-read-ids.txt IDs into data/read-ids.txt 5. Create a pull request @@ -28,7 +28,7 @@ import time import re import traceback -from formatter import format_all, validate +from aformatter import format_all, validate with open('temp-atlas.json', 'w', encoding='utf-8') as OUT_FILE, open('temp-read-ids.txt', 'w') as READ_IDS_FILE, open('temp-atlas-manual.txt', 'w', encoding='utf-8') as FAIL_FILE: diff --git a/tools/requirements.txt b/tools/requirements.txt new file mode 100644 index 00000000..9d9d90a4 --- /dev/null +++ b/tools/requirements.txt @@ -0,0 +1 @@ +praw \ No newline at end of file diff --git a/tools/one-off/scale_back.py b/tools/scale_back.py similarity index 100% rename from tools/one-off/scale_back.py rename to tools/scale_back.py