diff options
| author | Konrad Delong <konryd@gmail.com> | 2010-05-13 22:02:57 +0200 |
|---|---|---|
| committer | Konrad Delong <konryd@gmail.com> | 2010-05-13 22:02:57 +0200 |
| commit | f55d24663084076ea2f0dc4206eb2a8f240830cd (patch) | |
| tree | 7f8a5125c7e83fbc050181a91f5f3805802bdc69 /src/distutils2/command/upload_docs.py | |
| parent | f53872cabacc4fc45b60bfb9f6317376544bcfcc (diff) | |
| download | disutils2-f55d24663084076ea2f0dc4206eb2a8f240830cd.tar.gz | |
added zip_dir_into
Diffstat (limited to 'src/distutils2/command/upload_docs.py')
| -rw-r--r-- | src/distutils2/command/upload_docs.py | 15 |
1 files changed, 14 insertions, 1 deletions
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 = [ |
