1515def make_tarball (base_name , base_dir , compress = "gzip" ,
1616 verbose = 0 , dry_run = 0 ):
1717 """Create a (possibly compressed) tar file from all the files under
18- 'base_dir'. 'compress' must be "gzip" (the default), "compress",
19- "bzip2", or None. Both "tar" and the compression utility named by
20- 'compress' must be on the default program search path, so this is
21- probably Unix-specific. The output tar file will be named 'base_dir'
22- + ".tar", possibly plus the appropriate compression extension (".gz",
23- ".bz2" or ".Z"). Return the output filename."""
24-
18+ 'base_dir'. 'compress' must be "gzip" (the default), "compress",
19+ "bzip2", or None. Both "tar" and the compression utility named by
20+ 'compress' must be on the default program search path, so this is
21+ probably Unix-specific. The output tar file will be named 'base_dir' +
22+ ".tar", possibly plus the appropriate compression extension (".gz",
23+ ".bz2" or ".Z"). Return the output filename.
24+ """
2525 # XXX GNU tar 1.13 has a nifty option to add a prefix directory.
2626 # It's pretty new, though, so we certainly can't require it --
2727 # but it would be nice to take advantage of it to skip the
@@ -44,11 +44,11 @@ def make_tarball (base_name, base_dir, compress="gzip",
4444 archive_name = base_name + ".tar"
4545 mkpath (os .path .dirname (archive_name ), verbose = verbose , dry_run = dry_run )
4646 cmd = ["tar" , "-cf" , archive_name , base_dir ]
47- spawn (cmd , verbose = verbose , dry_run = dry_run )
47+ spawn (cmd , verbose = verbose , dry_run = dry_run )
4848
4949 if compress :
50- spawn ([compress ] + compress_flags [compress ] + [archive_name ],
51- verbose = verbose , dry_run = dry_run )
50+ spawn ([compress ] + compress_flags [compress ] + [archive_name ],
51+ verbose = verbose , dry_run = dry_run )
5252 return archive_name + compress_ext [compress ]
5353 else :
5454 return archive_name
@@ -57,22 +57,22 @@ def make_tarball (base_name, base_dir, compress="gzip",
5757
5858
5959def make_zipfile (base_name , base_dir , verbose = 0 , dry_run = 0 ):
60- """Create a zip file from all the files under 'base_dir'. The
61- output zip file will be named 'base_dir' + ".zip". Uses either the
62- InfoZIP "zip" utility (if installed and found on the default search
63- path) or the "zipfile" Python module (if available). If neither
64- tool is available, raises DistutilsExecError. Returns the name
65- of the output zip file."""
66-
60+ """Create a zip file from all the files under 'base_dir'. The output
61+ zip file will be named 'base_dir' + ".zip". Uses either the InfoZIP
62+ "zip" utility (if installed and found on the default search path) or
63+ the "zipfile" Python module (if available). If neither tool is
64+ available, raises DistutilsExecError. Returns the name of the output
65+ zip file.
66+ """
6767 # This initially assumed the Unix 'zip' utility -- but
6868 # apparently InfoZIP's zip.exe works the same under Windows, so
6969 # no changes needed!
7070
7171 zip_filename = base_name + ".zip"
7272 mkpath (os .path .dirname (zip_filename ), verbose = verbose , dry_run = dry_run )
7373 try :
74- spawn (["zip" , "-rq" , zip_filename , base_dir ],
75- verbose = verbose , dry_run = dry_run )
74+ spawn (["zip" , "-rq" , zip_filename , base_dir ],
75+ verbose = verbose , dry_run = dry_run )
7676 except DistutilsExecError :
7777
7878 # XXX really should distinguish between "couldn't find
@@ -96,14 +96,14 @@ def make_zipfile (base_name, base_dir, verbose=0, dry_run=0):
9696 def visit (z , dirname , names ):
9797 for name in names :
9898 path = os .path .normpath (os .path .join (dirname , name ))
99- if os .path .isfile (path ):
100- z .write (path , path )
99+ if os .path .isfile (path ):
100+ z .write (path , path )
101101
102102 if not dry_run :
103- z = zipfile .ZipFile (zip_filename , "wb" ,
104- compression = zipfile .ZIP_DEFLATED )
103+ z = zipfile .ZipFile (zip_filename , "wb" ,
104+ compression = zipfile .ZIP_DEFLATED )
105105
106- os .path .walk (base_dir , visit , z )
106+ os .path .walk (base_dir , visit , z )
107107 z .close ()
108108
109109 return zip_filename
@@ -143,9 +143,9 @@ def make_archive (base_name, format,
143143 if root_dir is not None :
144144 if verbose :
145145 print "changing into '%s'" % root_dir
146- base_name = os .path .abspath (base_name )
146+ base_name = os .path .abspath (base_name )
147147 if not dry_run :
148- os .chdir (root_dir )
148+ os .chdir (root_dir )
149149
150150 if base_dir is None :
151151 base_dir = os .curdir
@@ -161,12 +161,12 @@ def make_archive (base_name, format,
161161 func = format_info [0 ]
162162 for (arg ,val ) in format_info [1 ]:
163163 kwargs [arg ] = val
164- filename = apply (func , (base_name , base_dir ), kwargs )
164+ filename = apply (func , (base_name , base_dir ), kwargs )
165165
166166 if root_dir is not None :
167167 if verbose :
168168 print "changing back to '%s'" % save_cwd
169- os .chdir (save_cwd )
169+ os .chdir (save_cwd )
170170
171171 return filename
172172
0 commit comments