mirror of https://github.com/dirtbags/moth.git
more versatile logging, chdir into puzzle directory when loading category.py
This commit is contained in:
parent
74e871fe55
commit
846643dcb0
|
@ -72,9 +72,10 @@ class Puzzle:
|
||||||
self.randseed = category_seed * self.points
|
self.randseed = category_seed * self.points
|
||||||
self.rand = random.Random(self.randseed)
|
self.rand = random.Random(self.randseed)
|
||||||
|
|
||||||
def log(self, msg):
|
def log(self, *vals):
|
||||||
"""Add a new log message to this puzzle."""
|
"""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):
|
def read_stream(self, stream):
|
||||||
header = True
|
header = True
|
||||||
|
@ -258,11 +259,10 @@ class Category:
|
||||||
self.catmod = None
|
self.catmod = None
|
||||||
|
|
||||||
if os.path.exists(os.path.join(path, 'category.py')):
|
if os.path.exists(os.path.join(path, 'category.py')):
|
||||||
self.catmod = importlib.machinery.SourceFileLoader(
|
with pushd(path):
|
||||||
'catmod',
|
loader = importlib.machinery.SourceFileLoader('catmod', 'category.py')
|
||||||
os.path.join(path, 'category.py')).load_module()
|
self.catmod = loader.load_module()
|
||||||
self.pointvals.extend(self.catmod.points)
|
self.pointvals.extend(self.catmod.points)
|
||||||
self.pointvals = self.catmod.points[:]
|
|
||||||
else:
|
else:
|
||||||
for fpath in glob.glob(os.path.join(path, "[0-9]*")):
|
for fpath in glob.glob(os.path.join(path, "[0-9]*")):
|
||||||
pn = os.path.basename(fpath)
|
pn = os.path.basename(fpath)
|
||||||
|
|
Loading…
Reference in New Issue