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)
评论列表
文章目录