Files
Tank-Transfer-Station/tanktransfer/python-driver/persistence.py
Patrick McDonagh 0431e764cd Completes MAXH2O-53, starts MAXH2O-57
Completes IO programming.
Adds framework for pocloud driver from cookiecutter
2017-12-06 16:58:06 -06:00

22 lines
625 B
Python

"""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)
except Exception:
return False