From f55d24663084076ea2f0dc4206eb2a8f240830cd Mon Sep 17 00:00:00 2001 From: Konrad Delong Date: Thu, 13 May 2010 22:02:57 +0200 Subject: added zip_dir_into --- src/distutils2/command/upload_docs.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/distutils2/command') diff --git a/src/distutils2/command/upload_docs.py b/src/distutils2/command/upload_docs.py index f35cd55..8400b3d 100644 --- a/src/distutils2/command/upload_docs.py +++ b/src/distutils2/command/upload_docs.py @@ -1,6 +1,19 @@ -import os.path +import os.path, tempfile, zipfile from distutils2.core import Command +def zip_dir_into(directory, destination): + """Compresses recursively contents of directory into a zipfile located + under given destination. + """ + 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() + class upload_docs(Command): user_options = [ -- cgit v1.2.1