|
|
|
@ -26,6 +26,7 @@ def save_preset(filters, params, preset_name):
|
|
|
|
|
new_filt = []
|
|
|
|
|
for i, filter in enumerate(filt):
|
|
|
|
|
new_filt.append(filt[filter])
|
|
|
|
|
log.print_message("Saving filters as:", preset_name)
|
|
|
|
|
|
|
|
|
|
# Store preset to database
|
|
|
|
|
store_to_db(new_filt, preset_name)
|
|
|
|
@ -45,14 +46,14 @@ def store_to_db(preset, preset_name):
|
|
|
|
|
preset = json.loads(preset)
|
|
|
|
|
|
|
|
|
|
# If database doesn't exist, create it
|
|
|
|
|
if not exists("db.json"):
|
|
|
|
|
if not exists("conf/db.json"):
|
|
|
|
|
log.print_message("Storing preset to database")
|
|
|
|
|
with open("db.json", 'w') as db:
|
|
|
|
|
with open("conf/db.json", 'w') as db:
|
|
|
|
|
json.dump(preset, db)
|
|
|
|
|
else:
|
|
|
|
|
# If database exists, load it and check if preset already exists
|
|
|
|
|
try:
|
|
|
|
|
with open("db.json", 'r') as db:
|
|
|
|
|
with open("conf/db.json", 'r') as db:
|
|
|
|
|
db_presets = json.load(db)
|
|
|
|
|
|
|
|
|
|
# Empty file is an error, so we don't read it
|
|
|
|
@ -67,7 +68,7 @@ def store_to_db(preset, preset_name):
|
|
|
|
|
db_presets.update(preset)
|
|
|
|
|
|
|
|
|
|
# Finally write the updated entries to db file
|
|
|
|
|
with open("db.json", 'w') as db:
|
|
|
|
|
with open("conf/db.json", 'w') as db:
|
|
|
|
|
json.dump(db_presets, db, indent=4)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -91,10 +92,11 @@ def parse_conf(preset_name, filters, params, config_file):
|
|
|
|
|
if attribute != "name":
|
|
|
|
|
params[i][attribute] = value
|
|
|
|
|
parse_params(params[i])
|
|
|
|
|
|
|
|
|
|
log.print_message("Loaded preset:", preset_name,
|
|
|
|
|
"from file:", config_file)
|
|
|
|
|
else:
|
|
|
|
|
log.print_message("Preset not found")
|
|
|
|
|
log.print_message("Warning: Preset not found in config file")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def parse_params(params):
|
|
|
|
|