sync spectra_replay_normalize.py from production (case-insensitive tankModels/ prefix matching)
This commit is contained in:
@@ -10,17 +10,24 @@ MODEL_PREFIXES = ("tankModels/", "airModels/", "aircrafts/")
|
||||
|
||||
|
||||
def strip_model_prefix(unit: Any) -> str:
|
||||
"""Return a bare unit CDK from either ``foo`` or ``tankModels/foo``."""
|
||||
"""Return a bare unit CDK from either ``foo`` or ``tankModels/foo``.
|
||||
|
||||
Spectra is inconsistent about prefix casing across replays (observed both
|
||||
``tankModels/`` and ``tankmodels/`` on the wire), so the match is
|
||||
case-insensitive.
|
||||
"""
|
||||
value = str(unit or "").strip()
|
||||
lowered = value.lower()
|
||||
for prefix in MODEL_PREFIXES:
|
||||
if value.startswith(prefix):
|
||||
if lowered.startswith(prefix.lower()):
|
||||
return value[len(prefix):]
|
||||
return value
|
||||
|
||||
|
||||
def _model_path(unit: Any) -> str:
|
||||
value = str(unit or "").strip()
|
||||
return value if any(value.startswith(prefix) for prefix in MODEL_PREFIXES) else ""
|
||||
lowered = value.lower()
|
||||
return value if any(lowered.startswith(prefix.lower()) for prefix in MODEL_PREFIXES) else ""
|
||||
|
||||
|
||||
def _as_number(value: Any) -> float | int | None:
|
||||
|
||||
Reference in New Issue
Block a user