Restore clothing details for atlas prompts
This commit is contained in:
@@ -145,6 +145,26 @@ def _restore_axis_values_for_context(
|
||||
return values
|
||||
|
||||
|
||||
def _fallback_restore_axis_values(
|
||||
source_categories: list[dict[str, Any]] | None,
|
||||
axis_name: str,
|
||||
hardcore_position_config: dict[str, Any],
|
||||
) -> list[Any]:
|
||||
if not source_categories:
|
||||
return []
|
||||
values: list[Any] = []
|
||||
for category in source_categories:
|
||||
if not hardcore_position_policy.is_hardcore_sexual_category(category):
|
||||
continue
|
||||
for subcategory in category.get("subcategories", []):
|
||||
raw_axes = subcategory.get("item_axes")
|
||||
if isinstance(raw_axes, dict):
|
||||
values.extend(_list_from(raw_axes.get(axis_name)))
|
||||
if not values:
|
||||
return []
|
||||
return hardcore_position_policy.filter_hardcore_axis(axis_name, values, hardcore_position_config)
|
||||
|
||||
|
||||
def _restored_prompt_axis_values(
|
||||
rng: Any,
|
||||
subcategory: dict[str, Any],
|
||||
@@ -152,6 +172,7 @@ def _restored_prompt_axis_values(
|
||||
hardcore_position_config: dict[str, Any],
|
||||
women_count: int,
|
||||
men_count: int,
|
||||
source_categories: list[dict[str, Any]] | None = None,
|
||||
) -> dict[str, str]:
|
||||
restore_axes = hardcore_position_policy.normalize_restore_prompt_axes(
|
||||
hardcore_position_config.get("restore_prompt_axes") if isinstance(hardcore_position_config, dict) else []
|
||||
@@ -170,6 +191,8 @@ def _restored_prompt_axis_values(
|
||||
restored[axis_name] = existing
|
||||
continue
|
||||
values = _list_from(raw_axes.get(axis_name))
|
||||
if not values:
|
||||
values = _fallback_restore_axis_values(source_categories, axis_name, hardcore_position_config)
|
||||
if not values:
|
||||
continue
|
||||
values = _restore_axis_values_for_context(
|
||||
@@ -261,6 +284,7 @@ def select_category_item_route_result(
|
||||
parsed_hardcore_position_config,
|
||||
women_count,
|
||||
men_count,
|
||||
source_categories,
|
||||
)
|
||||
if restored_axis_values:
|
||||
restored_details = _unique_texts(list(restored_axis_values.values()))
|
||||
|
||||
Reference in New Issue
Block a user