@sync_loop_call(60 * 1000)
@gen.coroutine
def update_china_location():
    global china_location_map
    global china_map
    if not china_location_map:  # Fetch location_map file
        resp = yield GetPage(options.api_url + options.location_map_gist)
        if resp.code == 200:
            resp = escape.json_decode(resp.body)
            raw_url = resp['files']['location_map.json']['raw_url']
            resp = yield GetPage(raw_url)
            if resp.code == 200:
                china_location_map = escape.json_decode(resp.body)
            else:
                options.logger.error("Fetch raw data error %d, %s" %
                                     (resp.code, resp.message))
        else:
            options.logger.error((resp.code, resp.message) % "Get gist error %d, %s")
    else:  # update location_map file every hour
        if int(time.time()) % 36000 < 60:
            resp = yield update_file(options.api_url + options.location_map_gist,
                                     "location_map.json",
                                     china_location_map)
            if resp.code != 200:
                options.logger.error("update gists error %d, %s" % (resp.code, resp.message))

    temp_china_map = {}
    for city in options.city_list:
        temp_china_map[city] = {"score": 0, "stateInitColor": 6}

    for user in github_china:
        try:
            location = user["location"].lower()
            location = ','.join(location.strip().split())
        except Exception, e:
            options.logger.error("lower location error %s" % e)
            continue
        # because acording to geoname match china will match to shanghai
        if location == "china":
            continue
        if location in china_location_map:
            city = china_location_map[location]
        else:
            city = yield match_geoname(location)
        if city:
            temp_china_map[city]["score"] += 1
            china_location_map[location] = city
        else:
            options.logger.warning("location: %s can't match" % location)

    china_map = temp_china_map.copy()
dataset/ETHPy150Open cloudaice/simple-data/github/workers.py/update_china_location/swapped operands of `%`