Classify appearance templates by XML root

This commit is contained in:
2026-08-14 12:09:13 +03:00
parent 61c0ed1726
commit 5615e262a8
3 changed files with 31 additions and 2 deletions
+12 -2
View File
@@ -172,7 +172,7 @@ ONEC_TEMPLATE_PLATFORM_TYPES = [
"xml_type": "DataCompositionAppearanceTemplate",
"decoder": "data_composition_appearance",
"status": "not_implemented",
"aliases": ["МакетОформленияКомпоновкиДанных", "DataCompositionAppearanceTemplate"],
"aliases": ["МакетОформленияКомпоновкиДанных", "DataCompositionAppearanceTemplate", "AppearanceTemplate"],
},
{
"id": "external_component",
@@ -4087,6 +4087,7 @@ def declared_template_platform_type_from_part(part: dict[str, Any]) -> dict[str,
classification.get("template_type"),
classification.get("platform_type_id"),
classification.get("platform_type"),
classification.get("xml_root"),
]
)
candidates.extend(classification.get("strings_sample") or [])
@@ -4101,7 +4102,7 @@ def template_type_candidates_from_features(features: dict[str, Any], content_par
candidates: list[dict[str, Any]] = []
declared = normalize_onec_template_platform_type(features.get("declared_platform_type_id") or features.get("declared_platform_type"))
if declared:
declared.update({"confidence": "high", "evidence": ["TemplateType metadata"]})
declared.update({"confidence": "high", "evidence": [str(features.get("declared_platform_type_evidence") or "TemplateType metadata")]})
candidates.append(declared)
def append_candidate(candidate: dict[str, Any]) -> None:
@@ -4140,6 +4141,14 @@ def public_template_summary(
(template_type for template_type in (declared_template_platform_type_from_part(part) for part in parts) if template_type),
None,
)
declared_type_evidence = "TemplateType metadata"
if any(
normalize_onec_template_platform_type(
((part.get("classification") or {}).get("xml_root") if isinstance(part.get("classification"), dict) else None)
)
for part in parts
):
declared_type_evidence = "payload XML root"
features = {
"tabular_document": any(((part.get("features") or {}).get("tabular_document")) for part in content_parts),
"html": any(((part.get("features") or {}).get("html")) for part in content_parts),
@@ -4149,6 +4158,7 @@ def public_template_summary(
"declared_platform_type": declared_platform_type.get("name"),
"declared_platform_type_id": declared_platform_type.get("id"),
"declared_platform_xml_type": declared_platform_type.get("xml_type"),
"declared_platform_type_evidence": declared_type_evidence,
}
if declared_platform_type
else {}