update the defaults instead of overwriting them in case the settings "schema" has changed between versions
This commit is contained in:
parent
1c139f500e
commit
2a3700e6fe
1 changed files with 8 additions and 1 deletions
|
@ -1,6 +1,9 @@
|
||||||
import json, os
|
import json, os
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
|
import functions
|
||||||
|
from listing import YahooAuctionsItem
|
||||||
|
|
||||||
class BuypeebSettings:
|
class BuypeebSettings:
|
||||||
def __init__(self, location: str):
|
def __init__(self, location: str):
|
||||||
self.s = {}
|
self.s = {}
|
||||||
|
@ -8,6 +11,7 @@ class BuypeebSettings:
|
||||||
self.s['favouriteUpdateInterval'] = 5 * 60
|
self.s['favouriteUpdateInterval'] = 5 * 60
|
||||||
self.s['updateIntervalCritical'] = 60
|
self.s['updateIntervalCritical'] = 60
|
||||||
self.s['favouriteUpdateIntervalCritical'] = 30
|
self.s['favouriteUpdateIntervalCritical'] = 30
|
||||||
|
self.s['watchlist'] = []
|
||||||
self.location = location
|
self.location = location
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
|
@ -18,7 +22,7 @@ class BuypeebSettings:
|
||||||
os.makedirs(self.location, 0o755)
|
os.makedirs(self.location, 0o755)
|
||||||
open(self.location + "config.json", 'x')
|
open(self.location + "config.json", 'x')
|
||||||
try:
|
try:
|
||||||
self.s = json.load(open(self.location + "config.json", 'r'))
|
self.s.update(json.load(open(self.location + "config.json", 'r')))
|
||||||
except:
|
except:
|
||||||
print("Couldn't load settings - using defaults")
|
print("Couldn't load settings - using defaults")
|
||||||
|
|
||||||
|
@ -27,3 +31,6 @@ class BuypeebSettings:
|
||||||
|
|
||||||
def set(self, setting: str, value):
|
def set(self, setting: str, value):
|
||||||
self.s['setting'] = value
|
self.s['setting'] = value
|
||||||
|
|
||||||
|
def watch(self, name: string, url: string):
|
||||||
|
self.s['watchlist'].add(YahooAuctionsItem(name, url))
|
||||||
|
|
Loading…
Reference in a new issue