Refactor file handling with improved indentation

This commit is contained in:
2025-12-31 13:40:39 +01:00
committed by GitHub
parent f21c901d81
commit ccbb85c78e

View File

@@ -44,8 +44,11 @@ GENERIC_TEMPLATES = ["prompt_i2v.json", "prompt_vace_extend.json", "batch_i2v.js
# --- Helper Functions --- # --- Helper Functions ---
def load_config(): def load_config():
if CONFIG_FILE.exists(): if CONFIG_FILE.exists():
try: with open(CONFIG_FILE, 'r') as f: return json.load(f) try:
except: pass with open(CONFIG_FILE, 'r') as f:
return json.load(f)
except:
pass
return {"last_dir": str(Path.cwd()), "favorites": []} return {"last_dir": str(Path.cwd()), "favorites": []}
def save_config(current_dir, favorites): def save_config(current_dir, favorites):
@@ -54,8 +57,11 @@ def save_config(current_dir, favorites):
def load_snippets(): def load_snippets():
if SNIPPETS_FILE.exists(): if SNIPPETS_FILE.exists():
try: with open(SNIPPETS_FILE, 'r') as f: return json.load(f) try:
except: pass with open(SNIPPETS_FILE, 'r') as f:
return json.load(f)
except:
pass
return {} return {}
def save_snippets(snippets): def save_snippets(snippets):
@@ -81,7 +87,8 @@ def save_json(path, data):
if isinstance(existing, dict) and isinstance(data, dict): if isinstance(existing, dict) and isinstance(data, dict):
existing.update(data) existing.update(data)
data = existing data = existing
except: pass except:
pass
with open(path, 'w') as f: with open(path, 'w') as f:
json.dump(data, f, indent=4) json.dump(data, f, indent=4)