From ffc3be7e241d6d4886f29677af6bd3c0aa989583 Mon Sep 17 00:00:00 2001 From: 0x5c Date: Fri, 30 Oct 2020 07:07:56 -0400 Subject: [PATCH] Moved paths to pathlib Turns out most paths were already using pathlib, only remained some in lookup.py and fun.py Fixes #45 --- exts/fun.py | 2 +- exts/lookup.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/exts/fun.py b/exts/fun.py index 93ef379..856b617 100644 --- a/exts/fun.py +++ b/exts/fun.py @@ -19,7 +19,7 @@ import common as cmn class FunCog(commands.Cog): def __init__(self, bot: commands.Bot): self.bot = bot - with open("resources/words") as words_file: + with open(cmn.paths.resources / "words") as words_file: self.words = words_file.read().lower().splitlines() @commands.command(name="xkcd", aliases=["x"], category=cmn.cat.fun) diff --git a/exts/lookup.py b/exts/lookup.py index e1c585f..ee1b18e 100644 --- a/exts/lookup.py +++ b/exts/lookup.py @@ -9,6 +9,7 @@ the GNU General Public License, version 2. import threading +from pathlib import Path from ctyparser import BigCty @@ -17,11 +18,14 @@ from discord.ext import commands, tasks import common as cmn +cty_path = Path("./data/cty.json") + + class LookupCog(commands.Cog): def __init__(self, bot): self.bot = bot try: - self.cty = BigCty("./data/cty.json") + self.cty = BigCty(cty_path) except OSError: self.cty = BigCty() @@ -67,7 +71,7 @@ class LookupCog(commands.Cog): @tasks.loop(hours=24) async def _update_cty(self): - update = threading.Thread(target=run_update, args=(self.cty, "./data/cty.json")) + update = threading.Thread(target=run_update, args=(self.cty, cty_path)) update.start()