Plan 9 from Bell Labs’s /usr/web/sources/contrib/bichued/root/sys/lib/python/distutils/archive_util.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�
��c
@sdZdZddkZddklZddklZddklZddk	l
Z
dd	d	d
�Zd	d	d�Zhedgd
fd<edgdfd<edgdfd<edgdfd<egdfd<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|�dd
||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_dirRtverboseRtcompress_exttcompress_flagstarchive_nametcmd((s)/sys/lib/python/distutils/archive_util.pytmake_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'(RR
tnormpathtjointisfiletwriteRtinfo(tzRtnamestnameR
((s)/sys/lib/python/distutils/archive_util.pytvisitbs!twtcompression(tzipfiletImportErrorR	RRR
RRRRRtZipFiletZIP_DEFLATEDtwalktclose(	RRRRR#tzip_filenamet
zipoptionsR R((s)/sys/lib/python/distutils/archive_util.pytmake_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(
RtgetcwdR	RtdebugR
tabspathtchdirtcurdirR/tKeyErrorRtapply(
RR2troot_dirRRRtsave_cwdtkwargstformat_infotfunctargtvaltfilename((s)/sys/lib/python/distutils/archive_util.pytmake_archive�s,





(scompresssgzip(scompresssbzip2(scompressscompress(scompressN(t__doc__t__revision__Rtdistutils.errorsRtdistutils.spawnRtdistutils.dir_utilRt	distutilsRRR+R	R/R3RC(((s)/sys/lib/python/distutils/archive_util.pys<module>s$+9	

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].