From 2a3700e6fe5b27b1acafdb528d6028d7bc16f769 Mon Sep 17 00:00:00 2001 From: Lynne Date: Fri, 21 Aug 2020 20:52:40 +1000 Subject: [PATCH] update the defaults instead of overwriting them in case the settings "schema" has changed between versions --- settings.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/settings.py b/settings.py index 163cf60..06a445d 100644 --- a/settings.py +++ b/settings.py @@ -1,6 +1,9 @@ import json, os from os import path +import functions +from listing import YahooAuctionsItem + class BuypeebSettings: def __init__(self, location: str): self.s = {} @@ -8,6 +11,7 @@ class BuypeebSettings: self.s['favouriteUpdateInterval'] = 5 * 60 self.s['updateIntervalCritical'] = 60 self.s['favouriteUpdateIntervalCritical'] = 30 + self.s['watchlist'] = [] self.location = location def save(self): @@ -18,7 +22,7 @@ class BuypeebSettings: os.makedirs(self.location, 0o755) open(self.location + "config.json", 'x') try: - self.s = json.load(open(self.location + "config.json", 'r')) + self.s.update(json.load(open(self.location + "config.json", 'r'))) except: print("Couldn't load settings - using defaults") @@ -27,3 +31,6 @@ class BuypeebSettings: def set(self, setting: str, value): self.s['setting'] = value + + def watch(self, name: string, url: string): + self.s['watchlist'].add(YahooAuctionsItem(name, url))