Mercurial > repos > cmonjeau > ziptool
comparison zip.py @ 0:e466f86a4520 draft default tip
Imported from capsule None
| author | cmonjeau | 
|---|---|
| date | Tue, 07 Jul 2015 08:49:28 -0400 | 
| parents | |
| children | 
   comparison
  equal
  deleted
  inserted
  replaced
| -1:000000000000 | 0:e466f86a4520 | 
|---|---|
| 1 #!/usr/bin/env python | |
| 2 | |
| 3 """ | |
| 4 Create a zip archive | |
| 5 | |
| 6 usage: zip.py [options] | |
| 7 | |
| 8 See below for options | |
| 9 """ | |
| 10 | |
| 11 import os, subprocess, sys | |
| 12 import zipfile | |
| 13 | |
| 14 def __main__(): | |
| 15 | |
| 16 # init | |
| 17 output_zip = sys.argv[1] | |
| 18 | |
| 19 # create the zip archive | |
| 20 myarchive = zipfile.ZipFile(output_zip, 'w', allowZip64=True) | |
| 21 | |
| 22 # for all files, write in the archive | |
| 23 for i in range(2, len(sys.argv),2): | |
| 24 myarchive.write(sys.argv[i], os.path.basename(sys.argv[i+1])) | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 if __name__ == "__main__": __main__() | |
| 32 | 
