From b2a47ce11a2c7c3ab1643bf21f84da445e9d7040 Mon Sep 17 00:00:00 2001 From: Nikolaj Danger Date: Tue, 24 Mar 2020 15:49:31 +0100 Subject: [PATCH] Cleanup in resources --- Gwendolyn.py | 2 +- funcs/gwendolynFuncs.py | 3 --- funcs/lookup/lookupFuncs.py | 4 ++-- funcs/other/generators.py | 2 +- funcs/other/movie.py | 2 +- funcs/swfuncs/swchar.py | 20 +++++++++---------- funcs/swfuncs/swroll.py | 3 ++- help.txt => resources/help.txt | 0 {funcs/lookup => resources}/monsters.json | 0 {funcs/other => resources}/movies.txt | 12 +++++------ {funcs/other => resources}/names.txt | 0 {funcs/lookup => resources}/spells.json | 0 .../swcharacters.json | 0 .../skills.json => resources/swskills.json | 0 .../skills.txt => resources/swskills.txt | 0 .../swtemplates.json | 0 16 files changed, 23 insertions(+), 25 deletions(-) rename help.txt => resources/help.txt (100%) rename {funcs/lookup => resources}/monsters.json (100%) rename {funcs/other => resources}/movies.txt (98%) rename {funcs/other => resources}/names.txt (100%) rename {funcs/lookup => resources}/spells.json (100%) rename funcs/swfuncs/characters.json => resources/swcharacters.json (100%) rename funcs/swfuncs/skills.json => resources/swskills.json (100%) rename funcs/swfuncs/skills.txt => resources/swskills.txt (100%) rename funcs/swfuncs/templates.json => resources/swtemplates.json (100%) diff --git a/Gwendolyn.py b/Gwendolyn.py index 5615e22..96961dc 100644 --- a/Gwendolyn.py +++ b/Gwendolyn.py @@ -34,7 +34,7 @@ async def on_message(message): localtime = time.asctime( time.localtime(time.time()) ) print("\n"+localtime+"\n"+message.author.name+" ran !help") logging.info("\n"+localtime+"\n"+message.author.name+" ran !help") - with codecs.open("help.txt",encoding="utf-8") as f: + with codecs.open("resources/help.txt",encoding="utf-8") as f: text = f.read() print(text) em = discord.Embed(title = "Help", description = text,colour = 0x59f442) diff --git a/funcs/gwendolynFuncs.py b/funcs/gwendolynFuncs.py index 67428f3..ebb6a66 100644 --- a/funcs/gwendolynFuncs.py +++ b/funcs/gwendolynFuncs.py @@ -7,9 +7,6 @@ import urllib #used by imageFunc import imdb #used by movieFunc from .roll import dice -from .lookup import lookupFuncs -from .other import movie, generators -from .swfuncs import swchar, swroll def roll_dice(author : str, rollStr : str = "1d20"): print("Rolling "+str(rollStr)) diff --git a/funcs/lookup/lookupFuncs.py b/funcs/lookup/lookupFuncs.py index 05b6759..73b2c4e 100644 --- a/funcs/lookup/lookupFuncs.py +++ b/funcs/lookup/lookupFuncs.py @@ -25,7 +25,7 @@ def monsterFunc(content): logging.info("Monster doesn't exist in database\n") return("I don't know that monster...","","","","","") else: - data = json.load(open('funcs/lookup/monsters.json', encoding = "utf8")) + data = json.load(open('resources/monsters.json', encoding = "utf8")) for monster in data: if str(command) == monster["name"]: print("Found it!") @@ -117,7 +117,7 @@ def spellFunc(content): command = gf.cap(content.lower().replace("!spell ","")) print("Looking up "+command) logging.info("Looking up "+command) - data = json.load(open('funcs/lookup/spells.json', encoding = "utf8")) + data = json.load(open('resources/spells.json', encoding = "utf8")) if str(command) in data: print("Returning spell information") logging.info("Returning spell information") diff --git a/funcs/other/generators.py b/funcs/other/generators.py index 0a6b339..efa0533 100644 --- a/funcs/other/generators.py +++ b/funcs/other/generators.py @@ -8,7 +8,7 @@ def make_pairs(corpus): yield (corpus[i], corpus[i+1]) def nameGen(): - names = open('funcs/other/names.txt', encoding='utf8').read() + names = open('resources/names.txt', encoding='utf8').read() corpus = list(names) pairs = make_pairs(corpus) diff --git a/funcs/other/movie.py b/funcs/other/movie.py index 96d42dc..207159e 100644 --- a/funcs/other/movie.py +++ b/funcs/other/movie.py @@ -7,7 +7,7 @@ def movieFunc(): ia = imdb.IMDb() print("Picking a movie") - movs = open("funcs/other/movies.txt", "r") + movs = open("resources/movies.txt", "r") movlist = movs.read().split("\n") mov = random.choice(movlist) movs.close() diff --git a/funcs/swfuncs/swchar.py b/funcs/swfuncs/swchar.py index 8fa6451..92fad7c 100644 --- a/funcs/swfuncs/swchar.py +++ b/funcs/swfuncs/swchar.py @@ -2,7 +2,7 @@ import json import string def getName(user : str): - with open("funcs/swfuncs/characters.json", "r") as f: + with open("resources/swcharacters.json", "r") as f: data = json.load(f) if user in data: @@ -81,7 +81,7 @@ def characterSheet(character : dict): return name, text1+"\n\n"+text2+divider+text3 def charData(user : str,cmd : str): - with open("funcs/swfuncs/characters.json", "r") as f: + with open("resources/swcharacters.json", "r") as f: data = json.load(f) key = string.capwords(cmd.split(" ")[0]) @@ -107,7 +107,7 @@ def charData(user : str,cmd : str): if type(lookUpResult) is dict: data[user][key] = lookUpResult - with open("funcs/swfuncs/characters.json", "w") as f: + with open("resources/swcharacters.json", "w") as f: json.dump(data,f,indent = 4) return "Changed " + data[user]["Name"] + "'s " + key else: @@ -133,7 +133,7 @@ def charData(user : str,cmd : str): return "Can't add that" else: data[user][key] = cmd - with open("funcs/swfuncs/characters.json", "w") as f: + with open("resources/swcharacters.json", "w") as f: json.dump(data,f,indent = 4) return "Changed " + data[user]["Name"] + "'s " + key +" to " + cmd else: @@ -142,7 +142,7 @@ def charData(user : str,cmd : str): return "You don't have a character. You can make one with !swchar" def parseChar(user : str, cmd : str): - with open("funcs/swfuncs/characters.json", "r") as f: + with open("resources/swcharacters.json", "r") as f: data = json.load(f) if cmd == " ": @@ -157,30 +157,30 @@ def parseChar(user : str, cmd : str): if user in data: return characterSheet(data[user]) else: - with open("funcs/swfuncs/templates.json", "r") as f: + with open("resources/swtemplates.json", "r") as f: templates = json.load(f) newChar = templates["Character"] data[user] = newChar - with open("funcs/swfuncs/characters.json", "w") as f: + with open("resources/swcharacters.json", "w") as f: json.dump(data,f,indent = 4) return "", "Character for " + user + " created" else: if cmd == "purge": del data[user] - with open("funcs/swfuncs/characters.json", "w") as f: + with open("resources/swcharacters.json", "w") as f: json.dump(data,f,indent = 4) return "", "Character for " + user + " deleted" return "", charData(user,cmd) def lightsaberChar(user : str): - with open("funcs/swfuncs/characters.json", "r") as f: + with open("resources/swcharacters.json", "r") as f: data = json.load(f) if user in data: return data[user]["Lightsaber Characteristic"] def userHasChar(user : str): - with open("funcs/swfuncs/characters.json", "r") as f: + with open("resources/swcharacters.json", "r") as f: data = json.load(f) return user in data diff --git a/funcs/swfuncs/swroll.py b/funcs/swfuncs/swroll.py index e43a002..27182e0 100644 --- a/funcs/swfuncs/swroll.py +++ b/funcs/swfuncs/swroll.py @@ -2,10 +2,11 @@ import random import re import string import json +import os from . import swchar -with open("funcs/swfuncs/skills.json", "r") as f: +with open("resources/swskills.json", "r") as f: skillData = json.load(f) def roll(abi : int = 1, prof : int = 0, dif : int = 3, cha : int = 0, boo : int = 0, setb : int = 0, force : int = 0): diff --git a/help.txt b/resources/help.txt similarity index 100% rename from help.txt rename to resources/help.txt diff --git a/funcs/lookup/monsters.json b/resources/monsters.json similarity index 100% rename from funcs/lookup/monsters.json rename to resources/monsters.json diff --git a/funcs/other/movies.txt b/resources/movies.txt similarity index 98% rename from funcs/other/movies.txt rename to resources/movies.txt index f1a6295..874b825 100644 --- a/funcs/other/movies.txt +++ b/resources/movies.txt @@ -303,13 +303,13 @@ Fantastic Four Fantastic Mr Fox Fargo The Fast and the Furious -The Fast and the Furious 2 (2 Fast 2 Furious) -The Fast and the Furious 3 (Tokyo Drift) -The Fast and the Furious 4 (Fast & Furious) -The Fast and the Furious 5 (Fast Five) +2 Fast 2 Furious +The Fast and the Furious Tokyo Drift +Fast & Furious +Fast Five The Fast and the Furious 6 -The Fast and the Furious 7 (Furious 7) -The Fast and the Furious 8 (The Fate of the Furious) +Furious 7 +The Fate of the Furious Fast and Furious Presents: Hobbs and Shaw Fast Times of Ridgemont High The Fault in Our Stars diff --git a/funcs/other/names.txt b/resources/names.txt similarity index 100% rename from funcs/other/names.txt rename to resources/names.txt diff --git a/funcs/lookup/spells.json b/resources/spells.json similarity index 100% rename from funcs/lookup/spells.json rename to resources/spells.json diff --git a/funcs/swfuncs/characters.json b/resources/swcharacters.json similarity index 100% rename from funcs/swfuncs/characters.json rename to resources/swcharacters.json diff --git a/funcs/swfuncs/skills.json b/resources/swskills.json similarity index 100% rename from funcs/swfuncs/skills.json rename to resources/swskills.json diff --git a/funcs/swfuncs/skills.txt b/resources/swskills.txt similarity index 100% rename from funcs/swfuncs/skills.txt rename to resources/swskills.txt diff --git a/funcs/swfuncs/templates.json b/resources/swtemplates.json similarity index 100% rename from funcs/swfuncs/templates.json rename to resources/swtemplates.json