Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if in_place:
if USING_PYTHON2:
sys.exit("{}: -i/--in-place is not compatible with Python 2".format(program_name))
if args.output_format not in {"yaml", "annotated_yaml"}:
sys.exit("{}: -i/--in-place can only be used with -y/-Y".format(program_name))
input_streams = yq_args.pop("input_streams")
if len(input_streams) == 1 and input_streams[0].name == "":
msg = "{}: -i/--in-place can only be used with filename arguments, not on standard input"
sys.exit(msg.format(program_name))
for i, input_stream in enumerate(input_streams):
def exit_handler(arg=None):
if arg:
sys.exit(arg)
if i < len(input_streams):
yq_args["exit_func"] = exit_handler
yq(input_streams=[input_stream], output_stream=DeferredOutputStream(input_stream.name), **yq_args)
else:
yq(**yq_args)