cmd_position.py 文件源码

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

项目:pgocli 作者: pgocli 项目源码 文件源码
def cli(ctx, position):
    config = ctx.obj.get('config')

    # TODO: include google api key here
    geocoder = GoogleV3()

    try:
        loc = geocoder.geocode(position)

        if not loc:
            click.secho(
                'Could not geocode the specified location, aborting…',
                fg='red'
            )
            return False

        click.secho(
            'Found position: {}'.format(loc.address.encode('utf8')),
            fg='cyan'
        )
        config.position = dict(
            text=loc.address,
            latitude=loc.latitude,
            longitude=loc.longitude,
            altitude=loc.altitude
        )

        config.save()

    except GeocoderQueryError:
        click.secho(
            'Could not geocode the specified location, aborting…',
            fg='red'
        )
        return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号