annotate zip.py @ 0:e466f86a4520 draft default tip

Imported from capsule None
author cmonjeau
date Tue, 07 Jul 2015 08:49:28 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
1 #!/usr/bin/env python
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
2
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
3 """
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
4 Create a zip archive
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
5
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
6 usage: zip.py [options]
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
7
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
8 See below for options
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
9 """
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
10
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
11 import os, subprocess, sys
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
12 import zipfile
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
13
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
14 def __main__():
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
15
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
16 # init
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
17 output_zip = sys.argv[1]
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
18
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
19 # create the zip archive
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
20 myarchive = zipfile.ZipFile(output_zip, 'w', allowZip64=True)
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
21
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
22 # for all files, write in the archive
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
23 for i in range(2, len(sys.argv),2):
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
24 myarchive.write(sys.argv[i], os.path.basename(sys.argv[i+1]))
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
25
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
26
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
27
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
28
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
29
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
30
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
31 if __name__ == "__main__": __main__()
e466f86a4520 Imported from capsule None
cmonjeau
parents:
diff changeset
32