diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-09-08 02:53:42 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-09-08 02:53:42 (GMT) |
commit | 899f32fe1ef9882a4dedf16f0d2721a3e6beb8c6 (patch) | |
tree | 94f4dd1d723cd7163d27f75522438df742917f1a /Lib/shutil.py | |
parent | 90fd895197f485583af630ef2e34cbdea298abf7 (diff) | |
parent | d941d7a586c8ea2f8253d7b238b3a56522b77a83 (diff) | |
download | cpython-899f32fe1ef9882a4dedf16f0d2721a3e6beb8c6.zip cpython-899f32fe1ef9882a4dedf16f0d2721a3e6beb8c6.tar.gz cpython-899f32fe1ef9882a4dedf16f0d2721a3e6beb8c6.tar.bz2 |
Issue #24982: shutil.make_archive() with the "zip" format now adds entries
for directories (including empty directories) in ZIP file.
Added test for comparing shutil.make_archive() with the "zip" command.
Diffstat (limited to 'Lib/shutil.py')
-rw-r--r-- | Lib/shutil.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/shutil.py b/Lib/shutil.py index 8edabdb..f47a763 100644 --- a/Lib/shutil.py +++ b/Lib/shutil.py @@ -679,7 +679,16 @@ def _make_zipfile(base_name, base_dir, verbose=0, dry_run=0, logger=None): if not dry_run: with zipfile.ZipFile(zip_filename, "w", compression=zipfile.ZIP_DEFLATED) as zf: + path = os.path.normpath(base_dir) + zf.write(path, path) + if logger is not None: + logger.info("adding '%s'", path) for dirpath, dirnames, filenames in os.walk(base_dir): + for name in sorted(dirnames): + path = os.path.normpath(os.path.join(dirpath, name)) + zf.write(path, path) + if logger is not None: + logger.info("adding '%s'", path) for name in filenames: path = os.path.normpath(os.path.join(dirpath, name)) if os.path.isfile(path): |