Sample implemention of JSONtoTextParser

This commit is contained in:
Fabian Dill
2021-01-31 11:33:39 +01:00
parent 3d81f0cca7
commit 1da1e4eac6
3 changed files with 57 additions and 40 deletions

View File

@@ -43,7 +43,6 @@ def create_named_task(coro, *args, name=None):
return asyncio.create_task(coro, *args, name=name)
coloramaparser = HTMLtoColoramaParser()
class Context():
@@ -101,6 +100,8 @@ class Context():
self.finished_game = False
self.slow_mode = False
self.jsontotextparser = JSONtoTextParser(self)
@property
def endpoints(self):
if self.server:
@@ -957,8 +958,8 @@ async def process_server_cmd(ctx: Context, cmd: str, args: typing.Optional[dict]
elif cmd == 'Print':
logger.info(args["text"])
elif cmd == 'PrintHTML':
logger.info(coloramaparser.get_colorama_text(args["text"]))
elif cmd == 'PrintJSON':
logger.info(ctx.jsontotextparser(args["data"]))
elif cmd == 'HintPointUpdate':
ctx.hint_points = args['points']
@@ -1411,7 +1412,6 @@ async def main():
help="Turn off emitting a webserver for the webbrowser based user interface.")
args = parser.parse_args()
logging.basicConfig(format='%(message)s', level=getattr(logging, args.loglevel.upper(), logging.INFO))
if args.diff_file:
import Patch
logging.info("Patch file was supplied. Creating sfc rom..")