From f5bf4ed38d7551da434a1faa26e69800123951cd Mon Sep 17 00:00:00 2001 From: Marc Wouts Date: Mon, 29 Oct 2018 13:02:10 +0100 Subject: [PATCH] Tell which file is created/updated/replaced #113 --- jupytext/cli.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/jupytext/cli.py b/jupytext/cli.py index 7a483bd8d..3ccd8296f 100644 --- a/jupytext/cli.py +++ b/jupytext/cli.py @@ -89,6 +89,20 @@ def convert_notebook_files(nb_files, fmt, input_format=None, output=None, raise TypeError('Destination extension {} is not consistent' 'with format {} '.format(dest_ext, ext)) + if os.path.isfile(dest + ext): + if update: + action = ' (destination file updated)' + else: + action = ' (destination file replaced)' + else: + action = '' + + sys.stdout.write("[jupytext] Converting '{org_file}' to '{dest_file}'{format}{action}\n" + .format(dest_file=dest + ext, + org_file=nb_file, + format=" using format '{}'".format(format_name) if format_name else '', + action=action)) + save_notebook_as(notebook, nb_file, dest + ext, format_name, update) if notebooks_in_error: @@ -97,8 +111,7 @@ def convert_notebook_files(nb_files, fmt, input_format=None, output=None, def save_notebook_as(notebook, nb_file, nb_dest, format_name, combine): """Save notebook to file, in desired format""" - if combine and os.path.isfile(nb_dest) and \ - os.path.splitext(nb_dest)[1] == '.ipynb': + if combine and os.path.isfile(nb_dest) and os.path.splitext(nb_dest)[1] == '.ipynb': check_file_version(notebook, nb_file, nb_dest) nb_outputs = readf(nb_dest) combine_inputs_with_outputs(notebook, nb_outputs)