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

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


�
��c
@s�dZdZddkZddklZddklZhdd<dd<d	d
<Zdd
�Z	ddddddd�Z
ddd�Zd�ZdS(sFdistutils.file_util

Utility functions for operating on single files.
s5$Id: file_util.py 37828 2004-11-10 22:23:15Z loewis $i�N(tDistutilsFileError(tlogtcopyingshard linkingthardssymbolically linkingtsymiicCs�d}d}z�yt|d�}Wn1tij
o"\}}td||f�nXtii|�oIyti|�Wq�tij
o"\}}td||f�q�Xnyt|d�}Wn1tij
o"\}}td||f�nXx�y|i|�}Wn1tij
o"\}}td||f�nX|pPny|i	|�Wq�ij
o"\}}td||f�q�q�|o|i
�n|o|i
�nXdS(	s5Copy the file 'src' to 'dst'; both must be filenames.  Any error
    opening either file, reading from 'src', or writing to 'dst', raises
    DistutilsFileError.  Data is read/written in chunks of 'buffer_size'
    bytes (default 16k).  No attempt is made to handle anything apart from
    regular files.
    trbscould not open '%s': %sscould not delete '%s': %stwbscould not create '%s': %sscould not read from '%s': %sscould not write to '%s': %sN(tNonetopentosterrorRtpathtexiststunlinktreadtwritetclose(tsrctdsttbuffer_sizetfsrctfdstterrnoterrstrtbuf((s&/sys/lib/python/distutils/file_util.pyt_copy_file_contentssH
iicCsddkl}ddkl}	l}
l}l}tii	|�pt
d|�ntii|�o+|}
tii|tii
|��}ntii|�}
|o/|||�otid|�|dfSnyt|}Wn tj
otd|�nXtii
|�tii
|�jotid|||
�ntid|||�|o|d	fSntid
jo_ddk}y|i||d|�Wq�ij
o#}t
d|||df�q�n|d
joAtii|�otii||�pti||�q��|djoAtii|�otii||�pti||�q�}t||�|p|oati|�}|o"ti|||	||
f�n|oti||||��q�|d	fS(s�Copy a file 'src' to 'dst'.  If 'dst' is a directory, then 'src' is
    copied there with the same name; otherwise, it must be a filename.  (If
    the file exists, it will be ruthlessly clobbered.)  If 'preserve_mode'
    is true (the default), the file's mode (type and permission bits, or
    whatever is analogous on the current platform) is copied.  If
    'preserve_times' is true (the default), the last-modified and
    last-access times are copied as well.  If 'update' is true, 'src' will
    only be copied if 'dst' does not exist, or if 'dst' does exist but is
    older than 'src'.

    'link' allows you to make hard links (os.link) or symbolic links
    (os.symlink) instead of copying: set it to "hard" or "sym"; if it is
    None (the default), files are copied.  Don't set 'link' on systems that
    don't support it: 'copy_file()' doesn't check if hard or symbolic
    linking is available.

    Under Mac OS, uses the native file copy function in macostools; on
    other systems, uses '_copy_file_contents()' to copy file contents.

    Return a tuple (dest_name, copied): 'dest_name' is the actual name of
    the output file, and 'copied' is true if the file was copied (or would
    have been copied, if 'dry_run' true).
    i�(tnewer(tST_ATIMEtST_MTIMEtST_MODEtS_IMODEs4can't copy '%s': doesn't exist or not a regular files"not copying %s (output up-to-date)is&invalid value '%s' for 'link' arguments%s %s -> %sitmacNscould not copy '%s' to '%s': %sRR( tdistutils.dep_utilRtstatRRRRR	RtisfileRtisdirtjointbasenametdirnameRtdebugt_copy_actiontKeyErrort
ValueErrortinfotnamet
macostoolstcopyR
RtsamefiletlinktsymlinkRtutimetchmod(RRt
preserve_modetpreserve_timestupdateR0tverbosetdry_runRRRRRtdirtactionR-texctst((s&/sys/lib/python/distutils/file_util.pyt	copy_fileLsV&"%% 
)
)
""c
Cs�ddkl}l}l}l}l}ddk}	tid||�|o|Sn||�pt	d|�n||�ot
ii|||��}n%||�ot	d||f�n|||��pt	d||f�nd}
yt
i
||�WnNt
ij
o?\}}||	ijo
d	}
qYt	d
|||f�nX|
o�t||�yt
i|�Wq�t
ij
oV\}}yt
i|�Wnt
ij
onXt	dd||||f�q�Xn|S(
s%Move a file 'src' to 'dst'.  If 'dst' is a directory, the file will
    be moved into it with the same name; otherwise, 'src' is just renamed
    to 'dst'.  Return the new full name of the file.

    Handles cross-device moves on Unix using 'copy_file()'.  What about
    other systems???
    i�(RR"R#R%R&Nsmoving %s -> %ss#can't move '%s': not a regular files0can't move '%s': destination '%s' already existss2can't move '%s': destination '%s' not a valid pathiiscouldn't move '%s' to '%s': %ss+couldn't move '%s' to '%s' by copy/delete: sdelete '%s' failed: %s(tos.pathRR"R#R%R&RRR+RR	RR$trenameR
tEXDEVR=R
(
RRR7R8RR"R#R%R&Rtcopy_ittnumtmsg((s&/sys/lib/python/distutils/file_util.pyt	move_file�sP(




cCs?t|d�}x|D]}|i|d�qW|i�dS(s{Create a file with the specified name and write 'contents' (a
    sequence of strings without line terminators) to it.
    tws
N(RRR(tfilenametcontentstftline((s&/sys/lib/python/distutils/file_util.pyt
write_file�s
i@(
t__doc__t__revision__R	tdistutils.errorsRt	distutilsRRR(RR=RDRJ(((s&/sys/lib/python/distutils/file_util.pys<module>s"
	9e>

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.