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

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


�
��c@s�dZddkZddkZddkZddklZdddddd	d
ddd
g
Zd
efd��YZdd�Z	d�Z
d�Zd�Zd�Z
d�Zd�Zed�Zedd�Zd�Zd�ZdS(s�Utility functions for copying files and directory trees.

XXX The functions here don't copy the resource fork or other metadata on Mac.

i�N(tabspathtcopyfileobjtcopyfiletcopymodetcopystattcopytcopy2tcopytreetmovetrmtreetErrorcBseZRS((t__name__t
__module__(((s/sys/lib/python/shutil.pyR
siicCs2x+|i|�}|pPn|i|�qdS(s=copy data from file-like object fsrc to file-like object fdstN(treadtwrite(tfsrctfdsttlengthtbuf((s/sys/lib/python/shutil.pyRs
cCs�ttid�o5ytii||�SWqHtj
otSqHXntiitii|��tiitii|��jS(Ntsamefile(thasattrtostpathRtOSErrortFalsetnormcaseR(tsrctdst((s/sys/lib/python/shutil.pyt	_samefiles
cCs�t||�otd||f�nd}d}z/t|d�}t|d�}t||�Wd|o|i�n|o|i�nXdS(sCopy data from src to dsts`%s` and `%s` are the same filetrbtwbN(RR
tNonetopenRtclose(RRRR((s/sys/lib/python/shutil.pyR&scCsIttd�o5ti|�}ti|i�}ti||�ndS(sCopy mode bits from src to dsttchmodN(RRtstattS_IMODEtst_modeR"(RRtsttmode((s/sys/lib/python/shutil.pyR7scCsyti|�}ti|i�}ttd�o ti||i|if�nttd�oti||�ndS(s?Copy all stat info (mode bits, atime and mtime) from src to dsttutimeR"N(	RR#R$R%RR(tst_atimetst_mtimeR"(RRR&R'((s/sys/lib/python/shutil.pyR>s cCsVtii|�o%tii|tii|��}nt||�t||�dS(sVCopy data and mode bits ("cp src dst").

    The destination may be a directory.

    N(RRtisdirtjointbasenameRR(RR((s/sys/lib/python/shutil.pyRHs%
cCsVtii|�o%tii|tii|��}nt||�t||�dS(s]Copy data and all stat info ("cp -p src dst").

    The destination may be a directory.

    N(RRR+R,R-RR(RR((s/sys/lib/python/shutil.pyRSs%
cCs�ti|�}ti|�g}x|D]
}tii||�}tii||�}yu|o6tii|�o#ti|�}ti||�n5tii|�ot	|||�nt
||�Wq)ttifj
o%}	|i
||t|	�f�q)tj
o}
|i|
id�q)Xq)Wyt||�WnCtj
on2tj
o%}	|i||t|	�f�nX|o
t|�ndS(s�Recursively copy a directory tree using copy2().

    The destination directory must not already exist.
    If exception(s) occur, an Error is raised with a list of reasons.

    If the optional symlinks flag is true, symbolic links in the
    source tree result in symbolic links in the destination tree; if
    it is false, the contents of the files pointed to by symbolic
    links are copied.

    XXX Consider this example code rather than the ultimate tool.

    iN(RtlistdirtmakedirsRR,tislinktreadlinktsymlinkR+RRtIOErrorterrortappendtstrR
textendtargsRtWindowsErrorR(RRtsymlinkstnamesterrorstnametsrcnametdstnametlinktotwhyterr((s/sys/lib/python/shutil.pyR_s4
 !cCs�|o
d�}n|djo
d�}ng}yti|�}Wn1tij
o"}|ti|ti��nXx�|D]�}tii||�}yti|�i	}Wntij
o
d}nXt
i|�ot|||�q�yti
|�Wq�tij
o"}|ti
|ti��q�Xq�Wyti|�Wn/tij
o |ti|ti��nXdS(s�Recursively delete a directory tree.

    If ignore_errors is set, errors are ignored; otherwise, if onerror
    is set, it is called to handle the error with arguments (func,
    path, exc_info) where func is os.listdir, os.remove, or os.rmdir;
    path is the argument to that function that caused it to fail; and
    exc_info is a tuple returned by sys.exc_info().  If ignore_errors
    is false and onerror is None, an exception is raised.

    cWsdS(N((R8((s/sys/lib/python/shutil.pytonerror�scWs�dS(N((R8((s/sys/lib/python/shutil.pyRC�siN(RRR.R4tsystexc_infoRR,tlstatR%R#tS_ISDIRR	tremovetrmdir(Rt
ignore_errorsRCR;RBR=tfullnameR'((s/sys/lib/python/shutil.pyR	�s4


"cCs�yti||�Wn�tj
o|tii|�oHt||�otd||f�nt||dt�t	|�q�t
||�ti|�nXdS(s=Recursively move a file or directory to another location.

    If the destination is on our current filesystem, then simply use
    rename.  Otherwise, copy src to the dst and then remove src.
    A lot more could be done here...  A look at a mv.c shows a lot of
    the issues this implementation glosses over.

    s.Cannot move a directory '%s' into itself '%s'.R:N(RtrenameRRR+t	destinsrcR
RtTrueR	Rtunlink(RR((s/sys/lib/python/shutil.pyR�s

cCst|�it|��S(N(Rt
startswith(RR((s/sys/lib/python/shutil.pyRM�si@(t__doc__RRDR#tos.pathRt__all__tEnvironmentErrorR
RRRRRRRRRRR	RRM(((s/sys/lib/python/shutil.pys<module>s$				
		-(	

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.