avwx.parsing.summary

Contains functions for combining translations into a summary string

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

Condense the translation strings into a single report summary string

def taf(trans: avwx.structs.TafLineTrans) -> str:
30def taf(trans: TafLineTrans) -> str:
31    """Condense the translation strings into a single forecast summary string"""
32    summary = []
33    if trans.wind:
34        summary.append(f"Winds {trans.wind}")
35    if trans.visibility:
36        summary.append(f"Vis {trans.visibility[: trans.visibility.find(' (')].lower()}")
37    if trans.altimeter:
38        summary.append(f"Alt {trans.altimeter[: trans.altimeter.find(' (')]}")
39    if trans.wx_codes:
40        summary.append(trans.wx_codes)
41    if trans.clouds:
42        summary.append(trans.clouds.replace(" - Reported AGL", ""))
43    if trans.wind_shear:
44        summary.append(trans.wind_shear)
45    if trans.turbulence:
46        summary.append(trans.turbulence)
47    if trans.icing:
48        summary.append(trans.icing)
49    return ", ".join(summary)

Condense the translation strings into a single forecast summary string