minor updates

This commit is contained in:
Nico Melone
2024-10-04 18:55:54 -05:00
parent 7d1f9ca8e9
commit aa70b37efb
36 changed files with 2690 additions and 69 deletions

21
maplehmi/persistence.py Normal file
View File

@@ -0,0 +1,21 @@
"""Data persistance functions."""
# if more advanced persistence is needed, use a sqlite database
import json
def load(filename="persist.json"):
"""Load persisted settings from the specified file."""
try:
with open(filename, 'r') as persist_file:
return json.load(persist_file)
except Exception:
return False
def store(persist_obj, filename="persist.json"):
"""Store the persisting settings into the specified file."""
try:
with open(filename, 'w') as persist_file:
return json.dump(persist_obj, persist_file, indent=4)
except Exception:
return False