Extract item template metadata policy
This commit is contained in:
+9
-34
@@ -24,6 +24,7 @@ try:
|
||||
template_list as _template_list,
|
||||
)
|
||||
from . import camera_config as camera_policy
|
||||
from . import category_template_metadata as item_template_policy
|
||||
from . import character_config as character_policy
|
||||
from . import character_profile as character_profile_policy
|
||||
from . import category_cast_config as category_cast_policy
|
||||
@@ -45,7 +46,7 @@ try:
|
||||
sanitize_hardcore_axis_values as _sanitize_hardcore_axis_values,
|
||||
sanitize_hardcore_environment_anchors as _sanitize_hardcore_environment_anchors,
|
||||
)
|
||||
from .hardcore_action_metadata import normalize_hardcore_action_family, source_hardcore_action_family
|
||||
from .hardcore_action_metadata import source_hardcore_action_family
|
||||
from .hardcore_role_graphs import build_hardcore_role_graph
|
||||
except ImportError: # Allows local smoke tests with `python -c`.
|
||||
from category_library import (
|
||||
@@ -64,6 +65,7 @@ except ImportError: # Allows local smoke tests with `python -c`.
|
||||
template_list as _template_list,
|
||||
)
|
||||
import camera_config as camera_policy
|
||||
import category_template_metadata as item_template_policy
|
||||
import character_config as character_policy
|
||||
import character_profile as character_profile_policy
|
||||
import category_cast_config as category_cast_policy
|
||||
@@ -85,7 +87,7 @@ except ImportError: # Allows local smoke tests with `python -c`.
|
||||
sanitize_hardcore_axis_values as _sanitize_hardcore_axis_values,
|
||||
sanitize_hardcore_environment_anchors as _sanitize_hardcore_environment_anchors,
|
||||
)
|
||||
from hardcore_action_metadata import normalize_hardcore_action_family, source_hardcore_action_family
|
||||
from hardcore_action_metadata import source_hardcore_action_family
|
||||
from hardcore_role_graphs import build_hardcore_role_graph
|
||||
|
||||
|
||||
@@ -301,50 +303,23 @@ def _item_name(item: Any) -> str:
|
||||
|
||||
|
||||
def _template_metadata(item: Any) -> dict[str, Any]:
|
||||
if not isinstance(item, dict):
|
||||
return {}
|
||||
metadata: dict[str, Any] = {}
|
||||
for key in (
|
||||
"action_family",
|
||||
"action_type",
|
||||
"family",
|
||||
"position_family",
|
||||
"position_key",
|
||||
"position_keys",
|
||||
"formatter_hint",
|
||||
):
|
||||
if key in item:
|
||||
metadata[key] = item[key]
|
||||
return metadata
|
||||
return item_template_policy.template_metadata(item)
|
||||
|
||||
|
||||
def _template_position_family(metadata: dict[str, Any]) -> str:
|
||||
return _normalize_hardcore_position_family(
|
||||
metadata.get("position_family") or metadata.get("family"),
|
||||
"",
|
||||
)
|
||||
return item_template_policy.template_position_family(metadata)
|
||||
|
||||
|
||||
def _template_position_keys(metadata: dict[str, Any]) -> list[str]:
|
||||
keys: list[Any] = []
|
||||
if metadata.get("position_keys") is not None:
|
||||
raw_keys = metadata.get("position_keys")
|
||||
keys.extend(raw_keys if isinstance(raw_keys, list) else [raw_keys])
|
||||
if metadata.get("position_key") is not None:
|
||||
keys.append(metadata.get("position_key"))
|
||||
return _normalize_hardcore_position_values(keys)
|
||||
return item_template_policy.template_position_keys(metadata)
|
||||
|
||||
|
||||
def _template_action_family(metadata: dict[str, Any]) -> str:
|
||||
return normalize_hardcore_action_family(metadata.get("action_family") or metadata.get("action_type"), "")
|
||||
return item_template_policy.template_action_family(metadata)
|
||||
|
||||
|
||||
def _merge_position_keys(primary: list[str], fallback: list[str]) -> list[str]:
|
||||
merged: list[str] = []
|
||||
for key in [*primary, *fallback]:
|
||||
if key and key not in merged:
|
||||
merged.append(key)
|
||||
return merged
|
||||
return item_template_policy.merge_position_keys(primary, fallback)
|
||||
|
||||
|
||||
def _oral_acts_for_position(values: list[Any], position: str) -> list[Any]:
|
||||
|
||||
Reference in New Issue
Block a user