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)
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'])
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]
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]
def __init__(self): self.weather_service = WeatherService()