From 6d2c65f9c0a5ee04d2e98b9e151193c2338e03d5 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Fri, 28 Feb 2020 15:24:23 -0700 Subject: [PATCH] Fix some junk --- devel/devel-server.py | 4 +++- devel/moth.py | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/devel/devel-server.py b/devel/devel-server.py index 0534b32..4203e0d 100755 --- a/devel/devel-server.py +++ b/devel/devel-server.py @@ -153,7 +153,7 @@ class MothRequestHandler(http.server.SimpleHTTPRequestHandler): except KeyError: self.send_error( HTTPStatus.NOT_FOUND, - "File Not Found", + "File Not Found: %s" % self.req["filename"], ) return @@ -233,6 +233,8 @@ class MothRequestHandler(http.server.SimpleHTTPRequestHandler): HTTPStatus.NOT_IMPLEMENTED, "Unsupported method (%r)" % self.command, ) + +# I don't fully understand why you can't do this inside the class definition. MothRequestHandler.extensions_map[".mjs"] = "application/ecmascript" diff --git a/devel/moth.py b/devel/moth.py index 1e834f6..595ba9e 100644 --- a/devel/moth.py +++ b/devel/moth.py @@ -233,6 +233,12 @@ class Puzzle: except IndexError: pass self.files[name] = PuzzleFile(stream, name, not hidden) + elif key == 'files': + for file in val: + path = file["path"] + stream = open(path, "rb") + name = file.get("name") or path + self.files[name] = PuzzleFile(stream, name, not file.get("hidden")) elif key == 'script': stream = open(val, 'rb') self.add_script_stream(stream, val) @@ -400,10 +406,12 @@ class Puzzle: """Return a dict packaging of the puzzle.""" files = [fn for fn,f in self.files.items() if f.visible] + hidden = [fn for fn,f in self.files.items() if not f.visible] return { 'authors': self.get_authors(), 'hashes': self.hashes(), 'files': files, + 'hidden': hidden, 'scripts': self.scripts, 'pattern': self.pattern, 'body': self.html_body(),