seagull-game/app/pylocal/desktop.py

33 lines
936 B
Python
Raw Normal View History

2025-07-29 12:50:35 -07:00
import pathlib
from . import core
path_storagedir = pathlib.Path()
class JS_API:
def __init__(self):
self.debug_mode = False
2025-07-29 12:50:35 -07:00
def load_data(self, key):
if not (path_storagedir / key).exists():
return None
with open(path_storagedir / key) as fd_datafile:
try:
return fd_datafile.read()
except Exception as exc:
core.log.error(f"problem loading {key} (from {path_storagedir}): {exc}")
return None
def save_data(self, key, data):
with open(path_storagedir / key, "w") as fd_datafile:
try:
fd_datafile.write(data)
except Exception as exc:
core.log.error(f"problem saving {key} (to {path_storagedir}): {exc}")
def delete_data(self, key):
if (path_storagedir / key).exists():
(path_storagedir / key).unlink()
api = JS_API()