def taf_line(line: TafLineData, units: Units) -> str: """ Convert TafLineData into a string for text-to-speech """ speech = [] start = type_and_times(line.type, line.start_time, line.end_time, line.probability) if line.wind_direction and line.wind_speed: speech.append( wind( line.wind_direction, line.wind_speed, line.wind_gust, unit=units.wind_speed, )) if line.wind_shear: speech.append( wind_shear(line.wind_shear, units.altimeter, units.wind_speed)) if line.visibility: speech.append(visibility(line.visibility, units.visibility)) if line.altimeter: speech.append(altimeter(line.altimeter, units.altimeter)) if line.other: speech.append(other(line.other)) speech.append( translate.clouds(line.clouds, units.altitude).replace(" - Reported AGL", "")) if line.turbulance: speech.append(translate.turb_ice(line.turbulance, units.altitude)) if line.icing: speech.append(translate.turb_ice(line.icing, units.altitude)) return start + " " + (". ".join([l for l in speech if l])).replace(",", ".")
def test_turb_ice(self): """ Tests turbulance and icing translations """ for turbice, translation in ( ([], ''), (['540553'], 'Occasional moderate turbulence in clouds from 5500ft to 8500ft'), (['611005'], 'Light icing from 10000ft to 15000ft'), (['610023', '610062'], 'Light icing from 200ft to 3200ft, Light icing from 600ft to 2600ft'), ): self.assertEqual(translate.turb_ice(turbice), translation)
def test_turb_ice(self): """ Tests turbulance and icing translations """ for turbice, translation in ( ([], ''), (['540553'], 'Occasional moderate turbulence in clouds from 5500ft to 8500ft'), (['611005'], 'Light icing from 10000ft to 15000ft'), (['610023', '610062'], 'Light icing from 200ft to 3200ft, Light icing from 600ft to 2600ft' ), ): self.assertEqual(translate.turb_ice(turbice), translation)
def taf_line(line: TafLineData, units: Units) -> str: """ Convert TafLineData into a string for text-to-speech """ speech = [] start = type_and_times(line.type, line.start_time, line.end_time, line.probability) if line.wind_direction and line.wind_speed: speech.append(wind(line.wind_direction, line.wind_speed, line.wind_gust, unit=units.wind_speed)) if line.wind_shear: speech.append(wind_shear(line.wind_shear, units.altimeter, units.wind_speed)) if line.visibility: speech.append(visibility(line.visibility, units.visibility)) if line.altimeter: speech.append(altimeter(line.altimeter, units.altimeter)) if line.other: speech.append(other(line.other)) speech.append(translate.clouds(line.clouds, units.altitude).replace(' - Reported AGL', '')) if line.turbulance: speech.append(translate.turb_ice(line.turbulance, units.altitude)) if line.icing: speech.append(translate.turb_ice(line.icing, units.altitude)) return start + ' ' + ('. '.join([l for l in speech if l])).replace(',', '.')
def test_turb_ice(self): """ Tests turbulence and icing translations """ for turb_ice, translation in ( ([], ""), ( ["540553"], "Occasional moderate turbulence in clouds from 5500ft to 8500ft", ), (["611005"], "Light icing from 10000ft to 15000ft"), ( ["610023", "610062"], "Light icing from 200ft to 3200ft, Light icing from 600ft to 2600ft", ), ): self.assertEqual(translate.turb_ice(turb_ice), translation)