diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2023-06-10 22:29:24 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2023-06-10 22:29:24 +0300 |
commit | 3790c2205396cf860738f297e6ddc49cd2b2a03f (patch) | |
tree | b1ba6f227d3389071dd27346adcd24a593f8b327 /src/home/database/simple_state.py | |
parent | 2631c58961c2f5ec90be560a8f5152fe27339a90 (diff) |
new config: port openwrt_logger and webapiclient
Diffstat (limited to 'src/home/database/simple_state.py')
-rw-r--r-- | src/home/database/simple_state.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/home/database/simple_state.py b/src/home/database/simple_state.py index cada9c8..2b8ebe7 100644 --- a/src/home/database/simple_state.py +++ b/src/home/database/simple_state.py @@ -2,24 +2,26 @@ import os import json import atexit +from ._base import get_data_root_directory + class SimpleState: def __init__(self, - file: str, - default: dict = None, - **kwargs): + name: str, + default: dict = None): if default is None: default = {} elif type(default) is not dict: raise TypeError('default must be dictionary') - if not os.path.exists(file): + path = os.path.join(get_data_root_directory(), name) + if not os.path.exists(path): self._data = default else: - with open(file, 'r') as f: + with open(path, 'r') as f: self._data = json.loads(f.read()) - self._file = file + self._file = path atexit.register(self.__cleanup) def __cleanup(self): |