From e749dcb9ee4fa4f1a747f1f3ba130e46845f0548 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Tue, 31 Jan 2017 17:03:42 -0700 Subject: [PATCH] more versatile logging, chdir into puzzle directory when loading category.py --- tools/moth.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/moth.py b/tools/moth.py index e29f651..49c632e 100644 --- a/tools/moth.py +++ b/tools/moth.py @@ -72,9 +72,10 @@ class Puzzle: self.randseed = category_seed * self.points self.rand = random.Random(self.randseed) - def log(self, msg): + def log(self, *vals): """Add a new log message to this puzzle.""" - self.logs.append(str(msg)) + msg = ' '.join(str(v) for v in vals) + self.logs.append(msg) def read_stream(self, stream): header = True @@ -258,11 +259,10 @@ class Category: self.catmod = None if os.path.exists(os.path.join(path, 'category.py')): - self.catmod = importlib.machinery.SourceFileLoader( - 'catmod', - os.path.join(path, 'category.py')).load_module() - self.pointvals.extend(self.catmod.points) - self.pointvals = self.catmod.points[:] + with pushd(path): + loader = importlib.machinery.SourceFileLoader('catmod', 'category.py') + self.catmod = loader.load_module() + self.pointvals.extend(self.catmod.points) else: for fpath in glob.glob(os.path.join(path, "[0-9]*")): pn = os.path.basename(fpath)