def main():
    """
    Prints the app header, gets the weather in Carlsbad, California, USA and
    prints that information.
    """
    ui.print_header()
    weather_service = WeatherService(
        "https://www.wunderground.com/weather/us/ca/carlsbad"
    )
    weather_info = weather_service.parse_weather_info()
    ui.print_weather(weather_info)
Esempio n. 2
0
def main():
    container = ApplicationContext(ExampleApplicationContext())

    weather_service = WeatherService()
    geo_place = 'Maceio, AL'
    wind = weather_service.check_wind(geo_place)
    condition = weather_service.check_condition(geo_place)
    sunset = weather_service.check_sunset(geo_place)

    print('Direction: %s' % wind['wind']['direction'])
    print('Speed: %s' % wind['wind']['speed'])
    print('Condition: %s' % condition['item']['condition']['text'])
    print('Sunset: %s' % sunset['astronomy']['sunset'])

    weather_service = container.get_object('weather_service')
    geo_place = 'Maceio, AL'
    wind = weather_service.check_wind(geo_place)
    condition = weather_service.check_condition(geo_place)
    sunset = weather_service.check_sunset(geo_place)

    print('====== AOP ======')
    print('Direction: %s' % wind['wind']['direction'])
    print('Speed: %s' % wind['wind']['speed'])
    print('Condition: %s' % condition['item']['condition']['text'])
    print('Sunset: %s' % sunset['astronomy']['sunset'])
Esempio n. 3
0
class Forecaster(object):
    def __init__(self):
        self.weather_service = WeatherService()

    def forecast(self):
        reading = self.weather_service.barometer()
        forecasts = dict(rising='Going to rain', falling='Looks clear')
        return forecasts[reading]
Esempio n. 4
0
class Forecaster(object):
    def __init__(self):
        self.weather_service = WeatherService()

    def forecast(self):
        reading = self.weather_service.barometer()
        forecasts = dict(
                        rising = 'Going to rain',
                        falling = 'Looks clear'
                        )
        return forecasts[reading]
Esempio n. 5
0
 def __init__(self):
     self.weather_service = WeatherService()
Esempio n. 6
0
 def __init__(self):
     self.weather_service = WeatherService()