def RefreshDB(self, callback):
    """Refreshes the lookup database by iterating over all cities in
    the geoprocessor and querying google maps for address components
    for any that are missing.
    """
    def _OnLookup(city, barrier_cb, response):
      if response.code != 200:
        logging.error('error in google maps API query: %s' % response)
      else:
        try:
          json_response = json.loads(response.body)
          components = []
          if len(json_response['results']) > 0:
            for comp in json_response['results'][0]['address_components']:
              for t in comp['types']:
                if t in ('locality', 'administrative_area_level_1', 'country'):
                  components.append(comp)
                  break
          self._lookup_db[city.id] = components
        except:
          logging.exception(response.body % 'unable to parse google maps API response: %s')
      barrier_cb()

    with util.Barrier(callback) as b:
      def _ProcessCities(cities):
        start_time = time.time()
        lookup_count = 0
        for index in xrange(len(cities)):
          city = cities[index]
          if city.id not in self._lookup_db:
            lat, lon = float(city.lat), float(city.lon)
            logging.info('looking up %s (%f, %f) via google maps API' % (city.name, lat, lon))
            if lookup_count / (1.0 + time.time() - start_time) > options.options.query_rate:
              logging.info('pausing to slow API query rate')
              return self._io_loop.add_timeout(time.time() + 1.0, partial(_ProcessCities, cities[index:]))
            lookup_count += 1
            self._http_client.fetch('http://maps.googleapis.com/maps/api/geocode/json?latlng=%f,%f&sensor=false' %
                                    (lat, lon), callback=partial(_OnLookup, city, b.Callback()), method='GET')

      cities = self._geoproc.GetCities()
      _ProcessCities(cities)
dataset/ETHPy150Open viewfinderco/viewfinder/resources/geodata/geolookup.py/GeoLookup.RefreshDB/swapped operands of `%`