MCPcopy
hub / github.com/jupytext/jupytext / jupytext

Function jupytext

src/jupytext/cli.py:344–510  ·  view source on GitHub ↗

Entry point for the jupytext script

(args=None, *, notary=None)

Source from the content-addressed store, hash-verified

342
343
344def jupytext(args=None, *, notary=None):
345 """Entry point for the jupytext script"""
346 args = parse_jupytext_args(args)
347
348 def log(text):
349 if not args.quiet:
350 sys.stdout.write(text + "\n")
351
352 if args.version:
353 log(__version__)
354 return 0
355
356 if args.pre_commit:
357 warnings.warn(
358 "The --pre-commit argument is deprecated. "
359 "Please consider switching to the pre-commit.com framework "
360 "(let us know at https://github.com/jupytext/jupytext/issues "
361 "if that is an issue for you)",
362 DeprecationWarning,
363 )
364 if args.notebooks:
365 raise ValueError("--pre-commit takes notebooks from the git index. Do not pass any notebook here.")
366 args.notebooks = notebooks_in_git_index(args.input_format)
367 log("[jupytext] Notebooks in git index are:")
368 for nb_file in args.notebooks:
369 log(nb_file)
370
371 # Read notebook from stdin
372 if not args.notebooks:
373 if not args.pre_commit:
374 args.notebooks = ["-"]
375
376 if args.set_formats is not None:
377 # Replace empty string with None
378 args.update_metadata = recursive_update(args.update_metadata, {"jupytext": {"formats": args.set_formats or None}})
379 args.sync = True
380
381 if args.paired_paths:
382 if len(args.notebooks) != 1:
383 raise ValueError("--paired-paths applies to a single notebook")
384 print_paired_paths(args.notebooks[0], args.input_format)
385 return 1
386
387 if args.run_path:
388 args.execute = True
389
390 if (args.test or args.test_strict) and not args.output_format and not args.output and not args.sync:
391 raise ValueError("Please provide one of --to, --output or --sync")
392
393 if (
394 not args.output_format
395 and not args.output
396 and not args.sync
397 and not args.pipe
398 and not args.diff
399 and not args.check
400 and not args.update_metadata
401 and not args.format_options

Calls 13

parse_jupytext_argsFunction · 0.85
logFunction · 0.85
notebooks_in_git_indexFunction · 0.85
recursive_updateFunction · 0.85
print_paired_pathsFunction · 0.85
readFunction · 0.85
fmt_if_not_ipynbFunction · 0.85
compareFunction · 0.85
writesFunction · 0.85
long_form_one_formatFunction · 0.85
set_format_optionsFunction · 0.85
jupytext_single_fileFunction · 0.85

Used in the wild real call sites across dependent graphs

searching dependent graphs…