Hi, I’m using a file in the tmp directory. If there is an API, it would be good. My intention is to store caches for files and json used for the extension. I saw FileSystems service and I would like the files that I’m saving can persist when an upgrade happens to the extension.
class Settings:
"""
Store and load settings
"""
def __init__(self):
self.base_directory = "/tmp"
self.settingsfile = "stablehordesettings.json"
self.file = self.base_directory + "/" + self.settingsfile
def load(self) -> json:
if not os.path.exists(self.file):
return {"api_key": ANONYMOUS}
with open(self.file) as myfile:
return json.loads(myfile.read())
def save(self, settings: json):
with open(self.file, "w") as myfile:
myfile.write(json.dumps(settings))
os.chmod(self.file, 0o600)