feat(mma): Finalize Orchestrator Integration and fix all regressions
This commit is contained in:
@@ -170,11 +170,23 @@ def load_history(project_path: str | Path) -> dict:
|
||||
return {}
|
||||
|
||||
|
||||
def clean_nones(data):
|
||||
"""Recursively remove None values from a dictionary/list."""
|
||||
if isinstance(data, dict):
|
||||
return {k: clean_nones(v) for k, v in data.items() if v is not None}
|
||||
elif isinstance(data, list):
|
||||
return [clean_nones(v) for v in data if v is not None]
|
||||
return data
|
||||
|
||||
|
||||
def save_project(proj: dict, path: str | Path, disc_data: dict | None = None):
|
||||
"""
|
||||
Save the project TOML.
|
||||
If 'discussion' is present in proj, it is moved to the sibling history file.
|
||||
"""
|
||||
# Clean None values as TOML doesn't support them
|
||||
proj = clean_nones(proj)
|
||||
|
||||
# Ensure 'discussion' is NOT in the main project dict
|
||||
if "discussion" in proj:
|
||||
# If disc_data wasn't provided, use the one from proj
|
||||
@@ -188,6 +200,7 @@ def save_project(proj: dict, path: str | Path, disc_data: dict | None = None):
|
||||
tomli_w.dump(proj, f)
|
||||
|
||||
if disc_data:
|
||||
disc_data = clean_nones(disc_data)
|
||||
hist_path = get_history_path(path)
|
||||
with open(hist_path, "wb") as f:
|
||||
tomli_w.dump(disc_data, f)
|
||||
|
||||
Reference in New Issue
Block a user