cli.py 文件源码

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

项目:jsoncut 作者: json-transformations 项目源码 文件源码
def load_json(ctx, filename):
    if filename is None:
        if sys.stdin.isatty():
            click.echo(ctx.get_usage())
            click.echo("Try `jsoncut --help' for more information.")
            sys.exit(0)
        else:
            filename = '-'
    try:
        with click.open_file(filename) as file_:
            return json.load(file_)
    except EnvironmentError as e:
        if not sys.stdin.isatty():
            sys.stdin.read()
        click.echo(exc.default_error_mesg_fmt(e), err=True)
        sys.exit(1)
    except json.JSONDecodeError as e:
        click.echo(exc.default_error_mesg_fmt(e), err=True)
        sys.exit(1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号