feat(emulator): now using match structure, cleaner
This commit is contained in:
parent
edd608b233
commit
640c760ca0
|
@ -106,15 +106,13 @@ def state_manager(loop: asyncio.AbstractEventLoop):
|
||||||
while True:
|
while True:
|
||||||
for message in ps.listen():
|
for message in ps.listen():
|
||||||
if message["type"] == "message":
|
if message["type"] == "message":
|
||||||
data = message["data"].decode("utf-8")
|
match message["data"].decode("utf-8").split(":"):
|
||||||
|
case ["save"]:
|
||||||
# TODO: voir si plus clean possible ?
|
asyncio.ensure_future(utils.save(core), loop=loop)
|
||||||
# TODO: dev dans un docker ?
|
case ["load", filename]:
|
||||||
|
asyncio.ensure_future(utils.load(core, filename), loop=loop)
|
||||||
if data == "save":
|
case _:
|
||||||
asyncio.ensure_future(utils.save(core), loop=loop)
|
print(f"Command not understood: {message}")
|
||||||
elif data.startswith("load:"):
|
|
||||||
asyncio.ensure_future(utils.load(core, data.removeprefix("load:")), loop=loop)
|
|
||||||
|
|
||||||
|
|
||||||
async def emulator():
|
async def emulator():
|
||||||
|
|
Loading…
Reference in a new issue