Skip to content

Commit

Permalink
kynan#152 - adding dry run case
Browse files Browse the repository at this point in the history
  • Loading branch information
swateek committed Oct 10, 2022
1 parent 253420c commit a492cdb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions nbstripout/_nbstripout.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ def main():
warnings.simplefilter("ignore", category=UserWarning)
nb = read(f, as_version=NO_CONVERT)

nb = strip_output(nb, args.keep_output, args.keep_count, extra_keys, args.drop_empty_cells,
nb = strip_output(nb, args.keep_output, args.keep_count, extra_keys, args.dry_run, args.drop_empty_cells,
args.drop_tagged_cells.split(), args.strip_init_cells, _parse_size(args.max_size))

if args.dry_run:
Expand Down Expand Up @@ -517,7 +517,7 @@ def main():
warnings.simplefilter("ignore", category=UserWarning)
nb = read(input_stream, as_version=NO_CONVERT)

nb = strip_output(nb, args.keep_output, args.keep_count, extra_keys, args.drop_empty_cells,
nb = strip_output(nb, args.keep_output, args.keep_count, extra_keys, args.dry_run, args.drop_empty_cells,
args.drop_tagged_cells.split(), args.strip_init_cells, _parse_size(args.max_size))

if args.dry_run:
Expand Down
5 changes: 4 additions & 1 deletion nbstripout/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def strip_zeppelin_output(nb):
return nb


def strip_output(nb, keep_output, keep_count, extra_keys=[], drop_empty_cells=False, drop_tagged_cells=[],
def strip_output(nb, keep_output, keep_count, extra_keys=[], dry_run=False, drop_empty_cells=False, drop_tagged_cells=[],
strip_init_cells=False, max_size=0):
"""
Strip the outputs, execution count/prompt number and miscellaneous
Expand Down Expand Up @@ -129,6 +129,9 @@ def strip_output(nb, keep_output, keep_count, extra_keys=[], drop_empty_cells=Fa

# Remove the outputs, unless directed otherwise
if 'outputs' in cell:

if dry_run:
print("Dry Run!")

# Default behavior (max_size == 0) strips all outputs.
if not keep_output_this_cell:
Expand Down

0 comments on commit a492cdb

Please sign in to comment.