2023-06-15 16:22:35 +02:00
|
|
|
import json
|
|
|
|
import os
|
|
|
|
import secrets
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
patches_dir = "../data/patches/"
|
|
|
|
Path(patches_dir).mkdir(parents=True, exist_ok=True)
|
|
|
|
|
|
|
|
entry = None
|
|
|
|
entry_input = ""
|
|
|
|
|
2023-06-15 17:49:42 +02:00
|
|
|
print("Write/paste your JSON-formatted submission data here.")
|
2023-06-15 16:22:35 +02:00
|
|
|
while entry is None:
|
|
|
|
|
|
|
|
entry_input += input("> ")
|
|
|
|
try:
|
|
|
|
entry = json.loads(entry_input)
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
print()
|
2023-06-15 17:49:42 +02:00
|
|
|
print("Submission is valid!")
|
2023-06-15 16:22:35 +02:00
|
|
|
print()
|
2023-06-15 17:49:42 +02:00
|
|
|
print("Enter your username as the attribution to be shown on the About page.")
|
|
|
|
print("Leave it empty if you don't want to be attributed.")
|
2023-06-15 16:22:35 +02:00
|
|
|
print("You can use your Reddit username. Do not include the \"u/\" part.")
|
|
|
|
print("You can also your GitHub username, but add \"gh:\" before your username (e.g. \"gh:octocat\")")
|
|
|
|
author = input("Author: ")
|
|
|
|
|
|
|
|
if author:
|
|
|
|
entry['_author'] = author
|
|
|
|
|
2023-06-15 17:49:42 +02:00
|
|
|
filename = f'gh-{secrets.token_hex(2)}-{"-".join(entry["name"].split()).lower()}.json'
|
2023-06-15 16:22:35 +02:00
|
|
|
with open(f'{patches_dir}gh-{secrets.token_hex(2)}-{"-".join(entry["name"].split()).lower()}.json', 'w', encoding='utf-8') as out_file:
|
|
|
|
out_file.write(json.dumps(entry, ensure_ascii=False))
|
|
|
|
|
2023-06-15 17:49:42 +02:00
|
|
|
print("Patch created as " + filename + "!")
|
|
|
|
print("You can commit the created file directly, to which you can push and create a pull request after that.")
|