project/services/weather.py
def format_forecast(weather: Weather, unit: str) -> Dict[str, str]:
    """Formats an pyowm.weatherapi25.weather.Weather to an easy to use
    dictionary for the frontend.

    :param weather: A pyowm.weatherapi25.weather.Weather object
    :param unit: Defines the units for the temperature in the output
                 dictionary. Only accepts 'celsius', 'fahrenheit', 'kelvin' and
                 'random'.

    :raises AttributeError: If an invalid unit has been supplied
    """
    units = {'celsius', 'fahrenheit', 'kelvin'}
    unit_symbols = {'celsius': '°C', 'fahrenheit': '°F', 'kelvin': 'K'}

    if unit not in units and not unit == 'random':
        msg = "This is not a valid input unit, please enter one of the " \
              "following: {}"
        raise AttributeError(msg.format(' '.join(units)))

    if unit == 'random':
        unit = random.sample(units, 1)[0]

    output_dict = {}

    temperatures = weather.get_temperature(unit)
    temperature_naming = {'min': 'lowest',
                          'max': 'highest',
                          'eve': 'evening',
                          'morn': 'morning'}

    for t in temperatures:
        key = temperature_naming.get(t, t) + ' temperature'
        output_dict[key] = str(temperatures[t]) + ' ' + unit_symbols[unit]

    output_dict['weather_status'] = weather.get_status()
    return output_dict
Formats an pyowm.weatherapi25.weather.Weather to an easy to use
    dictionary for the frontend.

    :param weather: A pyowm.weatherapi25.weather.Weather object
    :param unit: Defines the units for the temperature in the output
                 dictionary. Only accepts 'celsius', 'fahrenheit', 'kelvin' and
                 'random'.

    :raises AttributeError: If an invalid unit has been supplied
    
Formats an pyowm.weatherapi25.weather.Weather to an easy to use
dictionary for the frontend.
Formats an pyowm . weatherapi25 . weather . Weather to an easy to use dictionary for the frontend .
def format_forecast(weather: Weather, unit: str) -> Dict[str, str]:
    units = {'celsius', 'fahrenheit', 'kelvin'}
    unit_symbols = {'celsius': '°C', 'fahrenheit': '°F', 'kelvin': 'K'}
    if unit not in units and not unit == 'random':
        msg = "This is not a valid input unit, please enter one of the " \
              "following: {}"
        raise AttributeError(msg.format(' '.join(units)))
    if unit == 'random':
        unit = random.sample(units, 1)[0]
    output_dict = {}
    temperatures = weather.get_temperature(unit)
    temperature_naming = {'min': 'lowest',
                          'max': 'highest',
                          'eve': 'evening',
                          'morn': 'morning'}
    for t in temperatures:
        key = temperature_naming.get(t, t) + ' temperature'
        output_dict[key] = str(temperatures[t]) + ' ' + unit_symbols[unit]
    output_dict['weather_status'] = weather.get_status()
    return output_dict
def format_forecast ( weather : Weather , unit : str ) -> Dict [ str , str ] : units = { 'celsius' , 'fahrenheit' , 'kelvin' } unit_symbols = { 'celsius' : '°C', fahrenheit': °F',  ' elvin':  ' '} if unit not in units and not unit == 'random' : msg = "This is not a valid input unit, please enter one of the " "following: {}" raise AttributeError ( msg . format ( ' ' . join ( units ) ) ) if unit == 'random' : unit = random . sample ( units , 1 ) [ 0 ] output_dict = { } temperatures = weather . get_temperature ( unit ) temperature_naming = { 'min' : 'lowest' , 'max' : 'highest' , 'eve' : 'evening' , 'morn' : 'morning' } for t in temperatures : key = temperature_naming . get ( t , t ) + ' temperature' output_dict [ key ] = str ( temperatures [ t ] ) + ' ' + unit_symbols [ unit ] output_dict [ 'weather_status' ] = weather . get_status ( ) return output_dict
Formats an pyowm.weatherapi25.weather.Weather to an easy to use
dictionary for the frontend.
Formats an pyowm . weatherapi25 . weather . Weather to an easy to use dictionary for the frontend .
"""Formats an pyowm.weatherapi25.weather.Weather to an easy to use
    dictionary for the frontend.

    :param weather: A pyowm.weatherapi25.weather.Weather object
    :param unit: Defines the units for the temperature in the output
                 dictionary. Only accepts 'celsius', 'fahrenheit', 'kelvin' and
                 'random'.

    :raises AttributeError: If an invalid unit has been supplied
    """
If an invalid unit has been supplied
If an invalid unit has been supplied
AttributeError
weather
Weather
A pyowm.weatherapi25.weather.Weather object
A pyowm . weatherapi25 . weather . Weather object
unit
str
Defines the units for the temperature in the output
dictionary. Only accepts 'celsius', 'fahrenheit', 'kelvin' and
'random'.
Defines the units for the temperature in the output dictionary . Only accepts ' celsius ' ' fahrenheit ' ' kelvin ' and ' random ' .