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

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


�
��c@s�dZdZddkZddkZddkTddklZlZddkl	Z	ha
dddd	�Zdddd
�Zddddddd�Z
d
�Zddd�Zd�ZdS(sWdistutils.dir_util

Utility functions for manipulating directories and directory trees.s5$Id: dir_util.py 39416 2005-08-26 15:20:46Z tim_one $i�N(t*(tDistutilsFileErrortDistutilsInternalError(tlogi�icCs�t|t�ptd|f�ntii|�}g}tii|�p
|djo|Sntitii	|��o|Sntii
|�\}}|g}xO|oG|o@tii|�o,tii
|�\}}|id|�q�Wx�|D]�}tii||�}tii	|�}	ti|	�oqnt
id|�|pQyti|�|i|�Wq�tj
o }
td||
df�q�Xndt|	<qW|S(sCreate a directory and any missing ancestor directories.  If the
       directory already exists (or if 'name' is the empty string, which
       means the current directory, which of course exists), then do
       nothing.  Raise DistutilsFileError if unable to create some
       directory along the way (eg. some sub-path exists, but is a file
       rather than a directory).  If 'verbose' is true, print a one-line
       summary of each mkdir to stdout.  Return the list of directories
       actually created.s(mkpath: 'name' must be a string (got %r)tiscreating %sscould not create '%s': %si�i(t
isinstancetStringTypesRtostpathtnormpathtisdirt
_path_createdtgettabspathtsplittinserttjoinRtinfotmkdirtappendtOSErrorR(tnametmodetverbosetdry_runtcreated_dirstheadttailttailstdtabs_headtexc((s%/sys/lib/python/distutils/dir_util.pytmkpaths<
 	%
c	Cszh}x3|D]+}d|tii|tii|��<q
W|i�}|i�x!|D]}t||d|�qYWdS(s�Create all the empty directories under 'base_dir' needed to
       put 'files' there.  'base_dir' is just the a name of a directory
       which doesn't necessarily exist yet; 'files' is a list of filenames
       to be interpreted relative to 'base_dir'.  'base_dir' + the
       directory portion of every file in 'files' will be created if it
       doesn't already exist.  'mode', 'verbose' and 'dry_run' flags are as
       for 'mkpath()'.iRN(RRRtdirnametkeystsortR (	tbase_dirtfilesRRRtneed_dirtfilet	need_dirstdir((s%/sys/lib/python/distutils/dir_util.pytcreate_treeXs)
icCs�ddkl}|o%tii|�otd|�nyti|�}	WnBtij
o3\}
}|o
g}	q�td||f�nX|pt|�ng}x|	D]}
tii	||
�}tii	||
�}|oatii
|�oNti|�}ti
d||�|pti||�n|i|�q�tii|�o,|it||||||d|��q�||||||d|�|i|�q�W|S(s0Copy an entire directory tree 'src' to a new location 'dst'.  Both
       'src' and 'dst' must be directory names.  If 'src' is not a
       directory, raise DistutilsFileError.  If 'dst' does not exist, it is
       created with 'mkpath()'.  The end result of the copy is that every
       file in 'src' is copied to 'dst', and directories under 'src' are
       recursively copied to 'dst'.  Return the list of files that were
       copied or might have been copied, using their output name.  The
       return value is unaffected by 'update' or 'dry_run': it is simply
       the list of all files under 'src', with the names changed to be
       under 'dst'.

       'preserve_mode' and 'preserve_times' are the same as for
       'copy_file'; note that they only apply to regular files, not to
       directories.  If 'preserve_symlinks' is true, symlinks will be
       copied as symlinks (on platforms that support them!); otherwise
       (the default), the destination of the symlink will be copied.
       'update' and 'verbose' are the same as for 'copy_file'.i�(t	copy_files&cannot copy tree '%s': not a directoryserror listing files in '%s': %sslinking %s -> %sR(tdistutils.file_utilR+RRR
RtlistdirterrorR RtislinktreadlinkRRtsymlinkRtextendt	copy_tree(tsrctdstt
preserve_modetpreserve_timestpreserve_symlinkstupdateRRR+tnamesterrnoterrstrtoutputstntsrc_nametdst_namet	link_dest((s%/sys/lib/python/distutils/dir_util.pyR3psB
cCs�xzti|�D]i}tii||�}tii|�o%tii|�ot||�q|iti|f�qW|iti	|f�dS(N(
RR-RRR
R/t_build_cmdtupleRtremovetrmdir(Rt	cmdtuplestftreal_f((s%/sys/lib/python/distutils/dir_util.pyRB�s'c	Cs�ddkl}tid|�|odSng}t||�x�|D]�}yMt|d|df�tii|d�}t	i
|�ot	|=nWqIttfj
o#}ti
||d|��qIXqIWdS(s�Recursively remove an entire directory tree.  Any errors are ignored
    (apart from being reported to stdout if 'verbose' is true).
    i�(tgrok_environment_errors'removing '%s' (and everything under it)Niiserror removing %s: (tdistutils.utilRHRRRBtapplyRRR
Rthas_keytIOErrorRtwarn(t	directoryRRRHREtcmdR
R((s%/sys/lib/python/distutils/dir_util.pytremove_tree�s 
	cCshtii|�\}}tidjoti|Sn.|dd!tijo||d}n|SdS(ssTake the full path 'path', and make it a relative path so
    it can be the second argument to os.path.join().
    tmaciiN(RRt
splitdrivetsystplatformtsep(Rtdrive((s%/sys/lib/python/distutils/dir_util.pytensure_relative�s(t__doc__t__revision__RRSttypestdistutils.errorsRRt	distutilsRRR R*R3RBRPRW(((s%/sys/lib/python/distutils/dir_util.pys<module>s"
CA	


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].