diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-09-08 02:47:01 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-09-08 02:47:01 (GMT) |
commit | fe45f65187fe36abc7049d949a5b206af204faa2 (patch) | |
tree | b06bde6a1b659b159b9d2faeda3c165a81d838df /Lib/shutil.py | |
parent | f3bdc1082f38ff22ca35e80f5a9c74ef48502f1b (diff) | |
download | cpython-fe45f65187fe36abc7049d949a5b206af204faa2.zip cpython-fe45f65187fe36abc7049d949a5b206af204faa2.tar.gz cpython-fe45f65187fe36abc7049d949a5b206af204faa2.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 e78a575..26dcfde 100644 --- a/Lib/shutil.py +++ b/Lib/shutil.py @@ -449,7 +449,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): |