feat(emulator): now using match structure, cleaner

This commit is contained in:
Laureηt 2022-02-09 11:48:56 +01:00
parent edd608b233
commit 640c760ca0
No known key found for this signature in database
GPG key ID: D88C6B294FD40994

View file

@ -106,15 +106,13 @@ def state_manager(loop: asyncio.AbstractEventLoop):
while True:
for message in ps.listen():
if message["type"] == "message":
data = message["data"].decode("utf-8")
# TODO: voir si plus clean possible ?
# TODO: dev dans un docker ?
if data == "save":
asyncio.ensure_future(utils.save(core), loop=loop)
elif data.startswith("load:"):
asyncio.ensure_future(utils.load(core, data.removeprefix("load:")), loop=loop)
match message["data"].decode("utf-8").split(":"):
case ["save"]:
asyncio.ensure_future(utils.save(core), loop=loop)
case ["load", filename]:
asyncio.ensure_future(utils.load(core, filename), loop=loop)
case _:
print(f"Command not understood: {message}")
async def emulator():