Preserve location route metadata
This commit is contained in:
+25
-4
@@ -322,6 +322,7 @@ def build_location_pool_json(
|
||||
merged_entries = entries
|
||||
|
||||
active = bool(enabled) and bool(merged_entries)
|
||||
theme = str(incoming.get("theme") or "") if combine_mode == "add" and incoming.get("enabled") else ""
|
||||
summary = (
|
||||
f"{apply_mode}; pools={len(merged_pool_names)}; locations={len(merged_entries)}"
|
||||
if active
|
||||
@@ -334,6 +335,7 @@ def build_location_pool_json(
|
||||
"pool_names": merged_pool_names,
|
||||
"scene_entries": merged_entries,
|
||||
"summary": summary,
|
||||
"theme": theme,
|
||||
},
|
||||
ensure_ascii=True,
|
||||
sort_keys=True,
|
||||
@@ -342,7 +344,7 @@ def build_location_pool_json(
|
||||
|
||||
def parse_location_config(location_config: str | dict[str, Any] | None) -> dict[str, Any]:
|
||||
if not location_config:
|
||||
return {"enabled": False, "apply_mode": "replace", "pool_names": [], "scene_entries": []}
|
||||
return {"enabled": False, "apply_mode": "replace", "pool_names": [], "scene_entries": [], "theme": ""}
|
||||
if isinstance(location_config, dict):
|
||||
raw = dict(location_config)
|
||||
else:
|
||||
@@ -361,6 +363,7 @@ def parse_location_config(location_config: str | dict[str, Any] | None) -> dict[
|
||||
"pool_names": [str(name) for name in _list_from(raw.get("pool_names")) if str(name).strip()],
|
||||
"scene_entries": entries,
|
||||
"summary": str(raw.get("summary") or ""),
|
||||
"theme": str(raw.get("theme") or ""),
|
||||
}
|
||||
|
||||
|
||||
@@ -432,6 +435,7 @@ def build_composition_pool_json(
|
||||
merged_entries = entries
|
||||
|
||||
active = bool(enabled) and bool(merged_entries)
|
||||
theme = str(incoming.get("theme") or "") if combine_mode == "add" and incoming.get("enabled") else ""
|
||||
summary = (
|
||||
f"{apply_mode}; pools={len(merged_pool_names)}; compositions={len(merged_entries)}"
|
||||
if active
|
||||
@@ -444,6 +448,7 @@ def build_composition_pool_json(
|
||||
"pool_names": merged_pool_names,
|
||||
"composition_entries": merged_entries,
|
||||
"summary": summary,
|
||||
"theme": theme,
|
||||
},
|
||||
ensure_ascii=True,
|
||||
sort_keys=True,
|
||||
@@ -452,7 +457,7 @@ def build_composition_pool_json(
|
||||
|
||||
def parse_composition_config(composition_config: str | dict[str, Any] | None) -> dict[str, Any]:
|
||||
if not composition_config:
|
||||
return {"enabled": False, "apply_mode": "replace", "pool_names": [], "composition_entries": []}
|
||||
return {"enabled": False, "apply_mode": "replace", "pool_names": [], "composition_entries": [], "theme": ""}
|
||||
if isinstance(composition_config, dict):
|
||||
raw = dict(composition_config)
|
||||
else:
|
||||
@@ -471,6 +476,7 @@ def parse_composition_config(composition_config: str | dict[str, Any] | None) ->
|
||||
"pool_names": [str(name) for name in _list_from(raw.get("pool_names")) if str(name).strip()],
|
||||
"composition_entries": entries,
|
||||
"summary": str(raw.get("summary") or ""),
|
||||
"theme": str(raw.get("theme") or ""),
|
||||
}
|
||||
|
||||
|
||||
@@ -512,8 +518,23 @@ def build_thematic_location_json(
|
||||
custom_compositions=composition_lines,
|
||||
composition_config=composition_config or "",
|
||||
)
|
||||
location_summary = json.loads(resolved_location_config).get("summary", "")
|
||||
composition_summary = json.loads(resolved_composition_config).get("summary", "")
|
||||
location_payload = json.loads(resolved_location_config)
|
||||
composition_payload = json.loads(resolved_composition_config)
|
||||
location_payload["theme"] = str(theme or "")
|
||||
composition_payload["theme"] = str(theme or "")
|
||||
themed_scene_entries = []
|
||||
for entry in location_payload.get("scene_entries") or []:
|
||||
if isinstance(entry, dict):
|
||||
themed_entry = dict(entry)
|
||||
themed_entry.setdefault("theme", str(theme or ""))
|
||||
themed_scene_entries.append(themed_entry)
|
||||
else:
|
||||
themed_scene_entries.append(entry)
|
||||
location_payload["scene_entries"] = themed_scene_entries
|
||||
resolved_location_config = json.dumps(location_payload, ensure_ascii=True, sort_keys=True)
|
||||
resolved_composition_config = json.dumps(composition_payload, ensure_ascii=True, sort_keys=True)
|
||||
location_summary = location_payload.get("summary", "")
|
||||
composition_summary = composition_payload.get("summary", "")
|
||||
summary = f"{theme}; locations={location_summary}; compositions={composition_summary}"
|
||||
return resolved_location_config, resolved_composition_config, summary
|
||||
|
||||
|
||||
Reference in New Issue
Block a user