* separated css/js/rule files to pak file (glorified zip) to reduce full rebuilds * implemented build cache * some frontend UI spiffing up
35 lines
983 B
Python
35 lines
983 B
Python
import pathlib
|
|
|
|
from . import core
|
|
|
|
path_storagedir = pathlib.Path()
|
|
|
|
class JS_API:
|
|
debug_mode = False
|
|
|
|
def __init__(self, debug_mode=False):
|
|
self.debug_mode = debug_mode
|
|
|
|
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() |