mirror of
				https://github.com/miaowware/qrm2.git
				synced 2025-11-04 04:00:21 -05:00 
			
		
		
		
	Moved paths to pathlib
Turns out most paths were already using pathlib, only remained some in lookup.py and fun.py Fixes #45
This commit is contained in:
		
							parent
							
								
									e8bb18ea8c
								
							
						
					
					
						commit
						ffc3be7e24
					
				@ -19,7 +19,7 @@ import common as cmn
 | 
				
			|||||||
class FunCog(commands.Cog):
 | 
					class FunCog(commands.Cog):
 | 
				
			||||||
    def __init__(self, bot: commands.Bot):
 | 
					    def __init__(self, bot: commands.Bot):
 | 
				
			||||||
        self.bot = 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()
 | 
					            self.words = words_file.read().lower().splitlines()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @commands.command(name="xkcd", aliases=["x"], category=cmn.cat.fun)
 | 
					    @commands.command(name="xkcd", aliases=["x"], category=cmn.cat.fun)
 | 
				
			||||||
 | 
				
			|||||||
@ -9,6 +9,7 @@ the GNU General Public License, version 2.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import threading
 | 
					import threading
 | 
				
			||||||
 | 
					from pathlib import Path
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from ctyparser import BigCty
 | 
					from ctyparser import BigCty
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -17,11 +18,14 @@ from discord.ext import commands, tasks
 | 
				
			|||||||
import common as cmn
 | 
					import common as cmn
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cty_path = Path("./data/cty.json")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class LookupCog(commands.Cog):
 | 
					class LookupCog(commands.Cog):
 | 
				
			||||||
    def __init__(self, bot):
 | 
					    def __init__(self, bot):
 | 
				
			||||||
        self.bot = bot
 | 
					        self.bot = bot
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            self.cty = BigCty("./data/cty.json")
 | 
					            self.cty = BigCty(cty_path)
 | 
				
			||||||
        except OSError:
 | 
					        except OSError:
 | 
				
			||||||
            self.cty = BigCty()
 | 
					            self.cty = BigCty()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -67,7 +71,7 @@ class LookupCog(commands.Cog):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @tasks.loop(hours=24)
 | 
					    @tasks.loop(hours=24)
 | 
				
			||||||
    async def _update_cty(self):
 | 
					    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()
 | 
					        update.start()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user