28 lines
716 B
Python
28 lines
716 B
Python
import json
|
|
import os.path
|
|
|
|
|
|
class Config:
|
|
LAST_OPENED_FILE = ""
|
|
AUTOSAVE_INTERVAL = 5 * 60 * 1000
|
|
|
|
def __init__(self, path: str):
|
|
self._path: str = path
|
|
|
|
self.load()
|
|
|
|
def load(self) -> None:
|
|
if os.path.exists(self._path):
|
|
with open(self._path, "r") as f:
|
|
config = json.load(f)
|
|
|
|
self.LAST_OPENED_FILE = config["last_opened_file"]
|
|
self.AUTOSAVE_INTERVAL = config["autosave_interval"]
|
|
|
|
def save(self) -> None:
|
|
with open(self._path, "w") as f:
|
|
json.dump({
|
|
"last_opened_file": self.LAST_OPENED_FILE,
|
|
"autosave_interval": self.AUTOSAVE_INTERVAL
|
|
}, f, indent=4)
|