desktop support
This commit is contained in:
32
app/pylocal/desktop.py
Normal file
32
app/pylocal/desktop.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import pathlib
|
||||
|
||||
from . import core
|
||||
|
||||
path_storagedir = pathlib.Path()
|
||||
|
||||
class JS_API:
|
||||
debug_mode = False
|
||||
|
||||
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()
|
Reference in New Issue
Block a user