buypeeb/settings.py

24 lines
673 B
Python
Raw Normal View History

import json, os
from os import path
class BuypeebSettings:
def __init__(self, location: str):
self.s = {}
self.s['updateInterval'] = 10 * 60
self.s['favouriteUpdateInterval'] = 5 * 60
self.s['updateIntervalCritical'] = 60
self.s['favouriteUpdateIntervalCritical'] = 30
self.location = location
def save(self):
json.dump(self.s, open(self.location + "config.json", 'w'))
def load(self):
if not path.isfile(self.location + "config.json"):
os.makedirs(self.location, 0o755)
open(self.location + "config.json", 'x')
try:
self.s = json.load(open(self.location + "config.json", 'r'))
except:
print("Couldn't load settings - using defaults")