

@respond_to('what time is it in (?P<place>.*)')
def what_time_is_it_in(self, message, place):
    'what time is it in ___: Say the time in almost any city on earth.'
    if ((not hasattr(settings, 'WORLD_WEATHER_ONLINE_KEY')) and (not hasattr(settings, 'WORLD_WEATHER_ONLINE_V2_KEY'))):
        self.say('I need a world weather online key to do that.\nYou can get one at http://developer.worldweatheronline.com, and then set the key as WORLD_WEATHER_ONLINE_V2_KEY', message=message)
    else:
        if hasattr(settings, 'WORLD_WEATHER_ONLINE_V2_KEY'):
            r = requests.get(('http://api2.worldweatheronline.com/free/v2/tz.ashx?q=%s&format=json&key=%s' % (place, settings.WORLD_WEATHER_ONLINE_V2_KEY)))
        elif hasattr(settings, 'WORLD_WEATHER_ONLINE_KEY'):
            r = requests.get(('http://api2.worldweatheronline.com/free/v1/tz.ashx?q=%s&format=json&key=%s' % (place, settings.WORLD_WEATHER_ONLINE_KEY)))
        resp = r.json()
        if (('request' in resp['data']) and (len(resp['data']['request']) > 0)):
            place = resp['data']['request'][0]['query']
            current_time = self.parse_natural_time(resp['data']['time_zone'][0]['localtime'])
            self.say(("It's %s in %s." % (self.to_natural_day_and_time(current_time), place)), message=message)
        else:
            self.say(("I couldn't find anywhere named %s." % (place,)), message=message)

dataset/ETHPy150Open skoczen/will/will/plugins/productivity/world_time.py TimePlugin.what_time_is_it_in/original