mirror of https://github.com/python/cpython
Issue #22219: The zipfile module CLI now adds entries for directories
(including empty directories) in ZIP file.
This commit is contained in:
commit
90c24c42b2
|
@ -1790,14 +1790,21 @@ def main(args = None):
|
||||||
if os.path.isfile(path):
|
if os.path.isfile(path):
|
||||||
zf.write(path, zippath, ZIP_DEFLATED)
|
zf.write(path, zippath, ZIP_DEFLATED)
|
||||||
elif os.path.isdir(path):
|
elif os.path.isdir(path):
|
||||||
|
if zippath:
|
||||||
|
zf.write(path, zippath)
|
||||||
for nm in os.listdir(path):
|
for nm in os.listdir(path):
|
||||||
addToZip(zf,
|
addToZip(zf,
|
||||||
os.path.join(path, nm), os.path.join(zippath, nm))
|
os.path.join(path, nm), os.path.join(zippath, nm))
|
||||||
# else: ignore
|
# else: ignore
|
||||||
|
|
||||||
with ZipFile(args[1], 'w') as zf:
|
with ZipFile(args[1], 'w') as zf:
|
||||||
for src in args[2:]:
|
for path in args[2:]:
|
||||||
addToZip(zf, src, os.path.basename(src))
|
zippath = os.path.basename(path)
|
||||||
|
if not zippath:
|
||||||
|
zippath = os.path.basename(os.path.dirname(path))
|
||||||
|
if zippath in ('', os.curdir, os.pardir):
|
||||||
|
zippath = ''
|
||||||
|
addToZip(zf, path, zippath)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -159,6 +159,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #22219: The zipfile module CLI now adds entries for directories
|
||||||
|
(including empty directories) in ZIP file.
|
||||||
|
|
||||||
- Issue #22449: In the ssl.SSLContext.load_default_certs, consult the
|
- Issue #22449: In the ssl.SSLContext.load_default_certs, consult the
|
||||||
enviromental variables SSL_CERT_DIR and SSL_CERT_FILE on Windows.
|
enviromental variables SSL_CERT_DIR and SSL_CERT_FILE on Windows.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue