more versatile logging, chdir into puzzle directory when loading category.py

This commit is contained in:
Neale Pickett 2017-01-31 17:03:42 -07:00
parent 74e871fe55
commit 846643dcb0
1 changed files with 7 additions and 7 deletions

View File

@ -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)