import json, os from os import path import functions from listing import YahooAuctionsItem 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.s['watchlist'] = [] 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.update(json.load(open(self.location + "config.json", 'r'))) except: print("Couldn't load settings - using defaults") def get(self, setting: str): # javalicious return self.s.get(setting, None) def set(self, setting: str, value): self.s['setting'] = value def watch(self, name: str, url: str): self.s['watchlist'].add(YahooAuctionsItem(name, url))