avwx.parsing.sanitization.pirep
PIREP sanitization support.
25 def sanitize_report_string(text: str, sans: Sanitization) -> str: 26 """Provide sanitization for operations that work better when the report is a string.""" 27 text = text.strip().upper().rstrip("=") 28 if len(text) < 4: 29 return text 30 # Standardize whitespace 31 text = " ".join(text.split()) 32 # Prevent changes to station ID 33 stid, text = text[:4], text[4:] 34 # Replace invalid key-value pairs 35 for key, rep in replacements.items(): 36 if key in text: 37 text = text.replace(key, rep) 38 sans.log(key, rep) 39 separated = separate_cloud_layers(text) 40 if text != separated: 41 sans.extra_spaces_needed = True 42 return stid + separated
Provide sanitization for operations that work better when the report is a string.