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