utils.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:goose-search 作者: rezemika 项目源码 文件源码
def try_geolocator_geocode(address):
    """
        Tries many times to get a geolocator object from an address,
        or None.
    """
    if settings.TESTING:
        return test_mockers.geolocator_object(address=address)
    attempts = 0
    while attempts < settings.GOOSE_META["max_geolocation_attempts"]:
        try:
            position = geolocator.geocode(
                address, language=get_language().split('-')[0]
            )
            return position
        except geopy.exc.GeopyError as e:
            attempts += 1
            if attempts == settings.GOOSE_META["max_geolocation_attempts"]:
                debug_logger.error(
                    "Too much geopy errors ({}). Aborting.".format(str(e))
                )
                return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号