From 313070754f669aa30d5b4a23d470fcd4c5c992cf Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 8 May 2021 09:39:48 -0700 Subject: [PATCH] Add callback_post_file. --- voussoirkit/spinal.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/voussoirkit/spinal.py b/voussoirkit/spinal.py index d4cd408..3480d15 100644 --- a/voussoirkit/spinal.py +++ b/voussoirkit/spinal.py @@ -90,6 +90,7 @@ def copy_dir( callback_permission_denied=None, callback_pre_directory=None, callback_pre_file=None, + callback_post_file=None, chunk_size=CHUNK_SIZE, destination_new_root=None, dry_run=False, @@ -142,6 +143,12 @@ def copy_dir( callback_pre_file: Passed into each `copy_file` as `callback_pre_copy`. + callback_post_file: + This function will be called after the file finishes copying with one + argument: the dotdict returned by copy_file. + If you think copy_dir should be rewritten as a generator instead, + I agree! + destination_new_root: Determine the destination path by calling `new_root(source, destination_new_root)`. @@ -219,6 +226,7 @@ def copy_dir( callback_directory_progress = callback_directory_progress or do_nothing callback_pre_directory = callback_pre_directory or do_nothing callback_pre_file = callback_pre_file or do_nothing + callback_post_file = callback_post_file or do_nothing bytes_per_second = limiter_or_none(bytes_per_second) files_per_second = limiter_or_none(files_per_second) @@ -298,6 +306,8 @@ def copy_dir( else: callback_directory_progress(copied.destination, written_bytes, total_bytes) + callback_post_file(copied) + if files_per_second is not None: files_per_second.limit(1)