³ò ¢l‡Jc@sçdZddkZddkZddkZddklZdddddd d d d d g Zd efd„ƒYZdd„Z d„Z d„Z d„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(tabspatht copyfileobjtcopyfiletcopymodetcopystattcopytcopy2tcopytreetmovetrmtreetErrorcBseZRS((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 o tSqHXntiitii|ƒƒ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% c Cs¦ti|ƒ}ti|ƒg}x|D] }tii||ƒ}tii||ƒ}yu|o6tii|ƒo#ti|ƒ}ti||ƒn5tii|ƒot |||ƒnt ||ƒWq)t ti 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.pyss$       -(