summaryrefslogtreecommitdiffstats
path: root/Lib/packaging/command/upload_docs.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-05-19 13:51:27 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-05-19 13:51:27 (GMT)
commit21a9c748aa8698c8201e30a58320d587f6bb7540 (patch)
treeddfcb60a800bc010237ee750a449c4639e5515e3 /Lib/packaging/command/upload_docs.py
parent0e3f3a70760f5ef1c0d1f7baf55046514b6bfbb6 (diff)
downloadcpython-21a9c748aa8698c8201e30a58320d587f6bb7540.zip
cpython-21a9c748aa8698c8201e30a58320d587f6bb7540.tar.gz
cpython-21a9c748aa8698c8201e30a58320d587f6bb7540.tar.bz2
packaging: use with open() instead of try/finally: close
Diffstat (limited to 'Lib/packaging/command/upload_docs.py')
-rw-r--r--Lib/packaging/command/upload_docs.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/Lib/packaging/command/upload_docs.py b/Lib/packaging/command/upload_docs.py
index 29ea6e9..47e6217 100644
--- a/Lib/packaging/command/upload_docs.py
+++ b/Lib/packaging/command/upload_docs.py
@@ -18,14 +18,13 @@ from packaging.command.cmd import Command
def zip_dir(directory):
"""Compresses recursively contents of directory into a BytesIO object"""
destination = BytesIO()
- zip_file = zipfile.ZipFile(destination, "w")
- for root, dirs, files in os.walk(directory):
- for name in files:
- full = os.path.join(root, name)
- relative = root[len(directory):].lstrip(os.path.sep)
- dest = os.path.join(relative, name)
- zip_file.write(full, dest)
- zip_file.close()
+ with zipfile.ZipFile(destination, "w") as zip_file:
+ for root, dirs, files in os.walk(directory):
+ for name in files:
+ full = os.path.join(root, name)
+ relative = root[len(directory):].lstrip(os.path.sep)
+ dest = os.path.join(relative, name)
+ zip_file.write(full, dest)
return destination