Normalize source name to fixed 5-letter code.
(source: str)
| 20 | |
| 21 | |
| 22 | def normalize_source(source: str) -> str: |
| 23 | """Normalize source name to fixed 5-letter code.""" |
| 24 | key = source.lower().replace(" ", "_").replace("-", "_") |
| 25 | if key in SOURCE_MAP: |
| 26 | return SOURCE_MAP[key] |
| 27 | # Try partial match |
| 28 | for map_key, map_val in SOURCE_MAP.items(): |
| 29 | if map_key in key or key in map_key: |
| 30 | return map_val |
| 31 | # Default: first 5 chars, uppercase, padded |
| 32 | return source[:5].upper().ljust(5) |
| 33 | |
| 34 | |
| 35 | # ============================================================================= |
no outgoing calls