Skip to content

Commit

Permalink
refactor: add try/catch logic into script execution
Browse files Browse the repository at this point in the history
  • Loading branch information
sijis committed Oct 16, 2023
1 parent a2629ca commit 0feafeb
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions tools/plugin-gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,10 @@
log.setLevel(logging.DEBUG)

DEFAULT_AVATAR = "https://upload.wikimedia.org/wikipedia/commons/5/5f/Err-logo.png"
BLACKLISTED = []

user_cache = {}

try:
with open("user_cache", "r") as f:
user_cache = eval(f.read())
except FileNotFoundError:
# File doesn't exist, so we continue on
log.info("No user cache existing, will be generating it for the first time.")
plugins = {}


def get_auth():
Expand Down Expand Up @@ -71,22 +66,11 @@ def add_blacklisted(repo):
f.write("\n")


plugins = {}


def save_plugins():
with open("repos.json", "w") as f:
json.dump(plugins, f, indent=2, separators=(",", ": "))


BLACKLISTED = []
try:
with open("blacklisted.txt", "r") as f:
BLACKLISTED = [line.strip() for line in f.readlines()]
except FileNotFoundError:
log.info("No blacklisted.txt found, no plugins will be blacklisted.")


def get_avatar_url(repo):
username = repo.split("/")[0]
if username in user_cache:
Expand Down Expand Up @@ -276,4 +260,17 @@ def main():


if __name__ == "__main__":
try:
with open("user_cache", "r") as f:
user_cache = eval(f.read())
except FileNotFoundError:
# File doesn't exist, so we continue on
log.info("No user cache existing, will be generating it for the first time.")

try:
with open("blacklisted.txt", "r") as f:
BLACKLISTED = [line.strip() for line in f.readlines()]
except FileNotFoundError:
log.info("No blacklisted.txt found, no plugins will be blacklisted.")

main()

0 comments on commit 0feafeb

Please sign in to comment.