From f3b485687ce8cb5d1f32d4812b16e0e95304dea6 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Thu, 2 Feb 2017 17:56:10 +0000 Subject: [PATCH] change category.py loading to deal with nutty cwd() issues and encourage on-demand computation --- tools/moth.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/moth.py b/tools/moth.py index 49c632e..c6e4436 100644 --- a/tools/moth.py +++ b/tools/moth.py @@ -112,7 +112,7 @@ class Puzzle: def read_directory(self, path): try: - fn = os.path.join(path, "puzzle.py") + fn = os.path.abspath(os.path.join(path, "puzzle.py")) loader = importlib.machinery.SourceFileLoader('puzzle_mod', fn) puzzle_mod = loader.load_module() except FileNotFoundError: @@ -260,9 +260,10 @@ class Category: if os.path.exists(os.path.join(path, 'category.py')): with pushd(path): - loader = importlib.machinery.SourceFileLoader('catmod', 'category.py') + fn = os.path.abspath('category.py') + loader = importlib.machinery.SourceFileLoader('category', fn) self.catmod = loader.load_module() - self.pointvals.extend(self.catmod.points) + self.pointvals.extend(self.catmod.pointvals()) else: for fpath in glob.glob(os.path.join(path, "[0-9]*")): pn = os.path.basename(fpath)