avwx.parsing.summary
Contains functions for combining translations into a summary string.
1"""Contains functions for combining translations into a summary string.""" 2 3# module 4from avwx.structs import MetarTrans, TafLineTrans 5 6 7def metar(trans: MetarTrans) -> str: 8 """Condense the translation strings into a single report summary string.""" 9 summary = [] 10 if trans.wind: 11 summary.append(f"Winds {trans.wind}") 12 if trans.visibility: 13 summary.append(f"Vis {trans.visibility[: trans.visibility.find(' (')].lower()}") 14 if trans.temperature: 15 summary.append(f"Temp {trans.temperature[: trans.temperature.find(' (')]}") 16 if trans.dewpoint: 17 summary.append(f"Dew {trans.dewpoint[: trans.dewpoint.find(' (')]}") 18 if trans.altimeter: 19 summary.append(f"Alt {trans.altimeter[: trans.altimeter.find(' (')]}") 20 if trans.wx_codes: 21 summary.append(trans.wx_codes) 22 if trans.clouds: 23 summary.append(trans.clouds.replace(" - Reported AGL", "")) 24 return ", ".join(summary) 25 26 27def taf(trans: TafLineTrans) -> str: 28 """Condense the translation strings into a single forecast summary string.""" 29 summary = [] 30 if trans.wind: 31 summary.append(f"Winds {trans.wind}") 32 if trans.visibility: 33 summary.append(f"Vis {trans.visibility[: trans.visibility.find(' (')].lower()}") 34 if trans.altimeter: 35 summary.append(f"Alt {trans.altimeter[: trans.altimeter.find(' (')]}") 36 if trans.wx_codes: 37 summary.append(trans.wx_codes) 38 if trans.clouds: 39 summary.append(trans.clouds.replace(" - Reported AGL", "")) 40 if trans.wind_shear: 41 summary.append(trans.wind_shear) 42 if trans.turbulence: 43 summary.append(trans.turbulence) 44 if trans.icing: 45 summary.append(trans.icing) 46 return ", ".join(summary)
8def metar(trans: MetarTrans) -> str: 9 """Condense the translation strings into a single report summary string.""" 10 summary = [] 11 if trans.wind: 12 summary.append(f"Winds {trans.wind}") 13 if trans.visibility: 14 summary.append(f"Vis {trans.visibility[: trans.visibility.find(' (')].lower()}") 15 if trans.temperature: 16 summary.append(f"Temp {trans.temperature[: trans.temperature.find(' (')]}") 17 if trans.dewpoint: 18 summary.append(f"Dew {trans.dewpoint[: trans.dewpoint.find(' (')]}") 19 if trans.altimeter: 20 summary.append(f"Alt {trans.altimeter[: trans.altimeter.find(' (')]}") 21 if trans.wx_codes: 22 summary.append(trans.wx_codes) 23 if trans.clouds: 24 summary.append(trans.clouds.replace(" - Reported AGL", "")) 25 return ", ".join(summary)
Condense the translation strings into a single report summary string.
28def taf(trans: TafLineTrans) -> str: 29 """Condense the translation strings into a single forecast summary string.""" 30 summary = [] 31 if trans.wind: 32 summary.append(f"Winds {trans.wind}") 33 if trans.visibility: 34 summary.append(f"Vis {trans.visibility[: trans.visibility.find(' (')].lower()}") 35 if trans.altimeter: 36 summary.append(f"Alt {trans.altimeter[: trans.altimeter.find(' (')]}") 37 if trans.wx_codes: 38 summary.append(trans.wx_codes) 39 if trans.clouds: 40 summary.append(trans.clouds.replace(" - Reported AGL", "")) 41 if trans.wind_shear: 42 summary.append(trans.wind_shear) 43 if trans.turbulence: 44 summary.append(trans.turbulence) 45 if trans.icing: 46 summary.append(trans.icing) 47 return ", ".join(summary)
Condense the translation strings into a single forecast summary string.