simplify: strip first/last char for squadron tag normalization
WT tags are always exactly one decorator char on each side, so a simple s[1:-1] is clearer than a regex strip. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+4
-2
@@ -1224,8 +1224,10 @@ def transform_to_local_format(api_data: Dict[str, Any]) -> Optional[Dict[str, An
|
|||||||
loser_winged = str(replay.get("loser") or "")
|
loser_winged = str(replay.get("loser") or "")
|
||||||
|
|
||||||
def _normalize_squadron_tag(raw: str) -> str:
|
def _normalize_squadron_tag(raw: str) -> str:
|
||||||
cleaned = re.sub(r'^[^A-Za-z0-9]+|[^A-Za-z0-9]+$', '', raw or "")
|
s = (raw or "").strip()
|
||||||
return cleaned or (raw or "").strip()
|
if len(s) >= 3 and not s[0].isalnum() and not s[-1].isalnum():
|
||||||
|
s = s[1:-1]
|
||||||
|
return s or raw or ""
|
||||||
|
|
||||||
winner_squadron = _normalize_squadron_tag(winner_winged)
|
winner_squadron = _normalize_squadron_tag(winner_winged)
|
||||||
loser_squadron = _normalize_squadron_tag(loser_winged)
|
loser_squadron = _normalize_squadron_tag(loser_winged)
|
||||||
|
|||||||
Reference in New Issue
Block a user