Add return value written_files.
This commit is contained in:
parent
8d9416cb2f
commit
10a312b996
1 changed files with 17 additions and 10 deletions
|
@ -198,8 +198,11 @@ def copy_directory(
|
||||||
verify_hash:
|
verify_hash:
|
||||||
Passed into each `copy_file` as `verify_hash`.
|
Passed into each `copy_file` as `verify_hash`.
|
||||||
|
|
||||||
Returns a dotdict containing at least `source`, `destination`,
|
Returns a dotdict containing at least these values:
|
||||||
and `written_bytes`. (Written bytes is 0 if all files already existed.)
|
`source` pathclass.Path
|
||||||
|
`destination` pathclass.Path
|
||||||
|
`written_files` int, number of files that were written
|
||||||
|
`written_bytes` int, number of bytes that were written
|
||||||
'''
|
'''
|
||||||
# Prepare parameters
|
# Prepare parameters
|
||||||
if not is_xor(destination, destination_new_root):
|
if not is_xor(destination, destination_new_root):
|
||||||
|
@ -283,6 +286,7 @@ def copy_directory(
|
||||||
yield (source_file, destination_file)
|
yield (source_file, destination_file)
|
||||||
|
|
||||||
walker = denester(walker)
|
walker = denester(walker)
|
||||||
|
written_files = 0
|
||||||
written_bytes = 0
|
written_bytes = 0
|
||||||
|
|
||||||
for (source_file, destination_file) in walker:
|
for (source_file, destination_file) in walker:
|
||||||
|
@ -313,7 +317,9 @@ def copy_directory(
|
||||||
verify_hash=verify_hash,
|
verify_hash=verify_hash,
|
||||||
)
|
)
|
||||||
|
|
||||||
written_bytes += copied.written_bytes
|
if copied.written:
|
||||||
|
written_files += 1
|
||||||
|
written_bytes += copied.written_bytes
|
||||||
|
|
||||||
if precalcsize is False:
|
if precalcsize is False:
|
||||||
callback_directory_progress(copied.destination, written_bytes, written_bytes)
|
callback_directory_progress(copied.destination, written_bytes, written_bytes)
|
||||||
|
@ -328,6 +334,7 @@ def copy_directory(
|
||||||
results = dotdict.DotDict(
|
results = dotdict.DotDict(
|
||||||
source=source,
|
source=source,
|
||||||
destination=destination,
|
destination=destination,
|
||||||
|
written_files=written_files,
|
||||||
written_bytes=written_bytes,
|
written_bytes=written_bytes,
|
||||||
default=None,
|
default=None,
|
||||||
)
|
)
|
||||||
|
@ -422,10 +429,10 @@ def copy_file(
|
||||||
If hash_class is None, then the global HASH_CLASS is used.
|
If hash_class is None, then the global HASH_CLASS is used.
|
||||||
|
|
||||||
Returns a dotdict containing at least these values:
|
Returns a dotdict containing at least these values:
|
||||||
`source` (Pathclass),
|
`source` pathclass.Path
|
||||||
`destination` (Pathclass),
|
`destination` pathclass.Path
|
||||||
`written` (False if file was skipped, True if written),
|
`written` bool, False if file was skipped, True if written
|
||||||
`written_bytes` (integer).
|
`written_bytes` int, number of bytes that were written
|
||||||
'''
|
'''
|
||||||
# Prepare parameters
|
# Prepare parameters
|
||||||
if not is_xor(destination, destination_new_root):
|
if not is_xor(destination, destination_new_root):
|
||||||
|
@ -787,9 +794,9 @@ def walk(
|
||||||
Yield pathclass.Path objects for files in the tree, similar to os.walk.
|
Yield pathclass.Path objects for files in the tree, similar to os.walk.
|
||||||
|
|
||||||
callback_permission_denied:
|
callback_permission_denied:
|
||||||
Passed directly into os.walk as onerror. If OSErrors (Permission Denied)
|
If OSErrors (Permission Denied) occur when trying to list a directory,
|
||||||
occur when trying to list a directory, your function will be called with
|
your function will be called with the exception object as the only
|
||||||
the exception object as the only argument.
|
argument.
|
||||||
|
|
||||||
exclude_directories:
|
exclude_directories:
|
||||||
A set of directories that will not be yielded. Members can be absolute
|
A set of directories that will not be yielded. Members can be absolute
|
||||||
|
|
Loading…
Reference in a new issue