�
��c
@sdZdZddkZddklZddklZddklZddk l
Z
dd d d
�Zd d d�Zhedgd
fd<edgdfd<edgdfd<edgdfd<egdfd<Zd�Zddd d d�ZdS(sodistutils.archive_util
Utility functions for creating archive files (tarballs, zip files,
that sort of thing).s8$Id: archive_util.py 37828 2004-11-10 22:23:15Z loewis $i�N(tDistutilsExecError(tspawn(tmkpath(tlogtgzipic Cshdd<dd<dd<}hdgd<dgd<dgd<}|dj o ||i�jo
td �n|d
}ttii|�d|�dd
||g}t|d|�|o2t|g|||gd|�|||Sn|SdS(s�Create a (possibly compressed) tar file from all the files under
'base_dir'. 'compress' must be "gzip" (the default), "compress",
"bzip2", or None. Both "tar" and the compression utility named by
'compress' must be on the default program search path, so this is
probably Unix-specific. The output tar file will be named 'base_dir' +
".tar", possibly plus the appropriate compression extension (".gz",
".bz2" or ".Z"). Return the output filename.
s.gzRs.bz2tbzip2s.Ztcompresss-f9s-fs=bad value for 'compress': must be None, 'gzip', or 'compress's.tartdry_runttars-cfN(tNonetkeyst
ValueErrorRtostpathtdirnameR( t base_nametbase_dirRtverboseRtcompress_exttcompress_flagstarchive_nametcmd((s)/sys/lib/python/distutils/archive_util.pytmake_tarballs$
c Cs#yddk}Wntj
o
d}nX|d}ttii|�d|�|djo^|o
d}nd}y td|||gd|�Wqtj
otd|�qXnct i
d ||�d
�}|p?|i|dd|i�}tii
|||�|i�n|S(
sqCreate a zip file from all the files under 'base_dir'. The output
zip file will be named 'base_dir' + ".zip". Uses either the "zipfile"
Python module (if available) or the InfoZIP "zip" utility (if installed
and found on the default search path). If neither tool is available,
raises DistutilsExecError. Returns the name of the output zip file.
i�Ns.zipRs-rs-rqtzipskunable to create zip file '%s': could neither import the 'zipfile' module nor find a standalone zip utilitys#creating '%s' and adding '%s' to itcSsnxg|D]_}tiitii||��}tii|�o%|i||�tid|�qqWdS(Nsadding '%s'(RR
tnormpathtjointisfiletwriteRtinfo(tzRtnamestnameR
((s)/sys/lib/python/distutils/archive_util.pytvisitbs!twtcompression(tzipfiletImportErrorR RRR
RRRRRtZipFiletZIP_DEFLATEDtwalktclose( RRRRR#tzip_filenamet
zipoptionsR R((s)/sys/lib/python/distutils/archive_util.pytmake_zipfile<s4
Rsgzip'ed tar-filetgztarRsbzip2'ed tar-filetbztarscompressed tar filetztarsuncompressed tar fileRsZIP fileRcCs1x*|D]}ti|�p|SqqWdSdS(N(tARCHIVE_FORMATSthas_keyR (tformatstformat((s)/sys/lib/python/distutils/archive_util.pytcheck_archive_formats}s
c
Cs*ti�}|dj o>tid|�tii|�}|pti|�qWn|djo
ti}nh|d<}yt |}Wn t
j
otd|�nX|d} x"|dD]\}
}|||
<q�Wt| ||f|�}|dj o!tid|�ti|�n|S(stCreate an archive file (eg. zip or tar). 'base_name' is the name
of the file to create, minus any format-specific extension; 'format'
is the archive format: one of "zip", "tar", "ztar", or "gztar".
'root_dir' is a directory that will be the root directory of the
archive; ie. we typically chdir into 'root_dir' before creating the
archive. 'base_dir' is the directory where we start archiving from;
ie. 'base_dir' will be the common prefix of all files and
directories in the archive. 'root_dir' and 'base_dir' both default
to the current directory. Returns the name of the archive file.
schanging into '%s'Rsunknown archive format '%s'iischanging back to '%s'N(
RtgetcwdR RtdebugR
tabspathtchdirtcurdirR/tKeyErrorRtapply(
RR2troot_dirRRRtsave_cwdtkwargstformat_infotfunctargtvaltfilename((s)/sys/lib/python/distutils/archive_util.pytmake_archive�s,
(scompresssgzip(scompresssbzip2(scompressscompress(scompressN(t__doc__t__revision__Rtdistutils.errorsRtdistutils.spawnRtdistutils.dir_utilRt distutilsRRR+R R/R3RC(((s)/sys/lib/python/distutils/archive_util.pys<module>s$+9
|