Ñò §ÚêLc@s8dZddkZddkZddkZddklZddkZddkZdddddd d d d d g Zd e fd„ƒYZ ye Wne j o dZ nXdd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zedd„Zedd„Zd„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/usr/lib64/python2.6/shutil.pyR siicCs2x+|i|ƒ}|pPn|i|ƒqdS(s=copy data from file-like object fsrc to file-like object fdstN(treadtwrite(tfsrctfdsttlengthtbuf((s/usr/lib64/python2.6/shutil.pyRs cCsttidƒo2ytii||ƒSWqEtj otSXntiitii|ƒƒtiitii|ƒƒjS(Ntsamefile(thasattrtostpathRtOSErrortFalsetnormcaseR(tsrctdst((s/usr/lib64/python2.6/shutil.pyt _samefile!s c Cs“t||ƒotd||fƒ‚nt|dƒiiƒ}zF|~}t|dƒiiƒ}z|~}t||ƒWdQXWdQXdS(sCopy data from src to dsts`%s` and `%s` are the same filetrbtwbN(RR topent__exit__t __enter__R(RRt_[1]Rt_[2]R((s/usr/lib64/python2.6/shutil.pyR-s &&cCsIttdƒo5ti|ƒ}ti|iƒ}ti||ƒndS(sCopy mode bits from src to dsttchmodN(RRtstattS_IMODEtst_modeR$(RRtsttmode((s/usr/lib64/python2.6/shutil.pyR6scCs÷ti|ƒ}ti|iƒ}ttdƒo ti||i|ifƒnttdƒoti||ƒnttdƒont|dƒo^yti ||i ƒWqót j o4}tt dƒ p|i t i jo‚qïqóXndS(sCCopy all stat info (mode bits, atime, mtime, flags) from src to dsttutimeR$tchflagstst_flagst EOPNOTSUPPN(RR%R&R'RR*tst_atimetst_mtimeR$R+R,RterrnoR-(RRR(R)twhy((s/usr/lib64/python2.6/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/usr/lib64/python2.6/shutil.pyRLs% 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(RRR2R3R4RR(RR((s/usr/lib64/python2.6/shutil.pyRWs% cs‡fd†}|S(sFunction that can be used as copytree() ignore parameter. Patterns is a sequence of glob-style patterns that are used to exclude filescs:g}x'ˆD]}|iti||ƒƒq Wt|ƒS(N(textendtfnmatchtfiltertset(Rtnamest ignored_namestpattern(tpatterns(s/usr/lib64/python2.6/shutil.pyt_ignore_patternsgs ((R<R=((R<s/usr/lib64/python2.6/shutil.pytignore_patternsbsc Csõti|ƒ}|dj o|||ƒ}n tƒ}ti|ƒg}x)|D]!}||joqRntii||ƒ}tii||ƒ} yx|o6tii|ƒo#ti|ƒ} ti | | ƒn8tii |ƒot || ||ƒnt || ƒWqRt tifj o%} |i|| t| ƒfƒqRtj o} |i| idƒqRXqRWyt||ƒWnRtj oF} tdj ot| tƒoqÝ|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. The optional ignore argument is a callable. If given, it is called with the `src` parameter, which is the directory being visited by copytree(), and `names` which is the list of `src` contents, as returned by os.listdir(): callable(src, names) -> ignored_names Since copytree() is called recursively, the callable will be called once for each directory that is copied. It returns a list of names relative to the `src` directory that should not be copied. XXX Consider this example code rather than the ultimate tool. iN(RtlistdirtNoneR8tmakedirsRR3tislinktreadlinktsymlinkR2RRtIOErrorterrortappendtstrR R5targsRRt WindowsErrort isinstance( RRtsymlinkstignoreR9R:terrorstnametsrcnametdstnametlinktoR1terr((s/usr/lib64/python2.6/shutil.pyRns>     !cCsà|o d„}n|djo d„}ny'tii|ƒotdƒ‚nWn0tj o$|tii|tiƒƒdSXg}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((RI((s/usr/lib64/python2.6/shutil.pytonerror»scWs‚dS(N((RI((s/usr/lib64/python2.6/shutil.pyRT¾ss%Cannot call rmtree on a symbolic linkNi(R@RRRBRtsystexc_infoR?RFR3tlstatR'R%tS_ISDIRR tremovetrmdir(Rt ignore_errorsRTR9RSROtfullnameR)((s/usr/lib64/python2.6/shutil.pyR ¯s@     "cCstii|itiiƒƒS(N(RRR4trstriptsep(R((s/usr/lib64/python2.6/shutil.pyt _basenameàscCsÿ|}tii|ƒoCtii|t|ƒƒ}tii|ƒotd|‚q\nyti||ƒWnˆtj o|tii|ƒoHt ||ƒotd||f‚nt ||dt ƒt |ƒqût ||ƒti|ƒnXdS(s“Recursively move a file or directory to another location. This is similar to the Unix "mv" command. If the destination is a directory or a symlink to a directory, the source is moved inside the directory. The destination path must not already exist. If the destination already exists but is not a directory, it may be overwritten depending on os.rename() semantics. If the destination is on our current filesystem, then rename() is used. Otherwise, src is copied to the destination and then removed. A lot more could be done here... A look at a mv.c shows a lot of the issues this implementation glosses over. s$Destination path '%s' already existss.Cannot move a directory '%s' into itself '%s'.RLN(RRR2R3R_texistsR trenameRt destinsrcRtTrueR Rtunlink(RRtreal_dst((s/usr/lib64/python2.6/shutil.pyRås cCsyt|ƒ}t|ƒ}|itiiƒp|tii7}n|itiiƒp|tii7}n|i|ƒS(N(RtendswithRRR^t startswith(RR((s/usr/lib64/python2.6/shutil.pyRbs  i@(t__doc__RRUR%tos.pathRR6R0t__all__tEnvironmentErrorR RJt NameErrorR@RRRRRRRR>RRR R_RRb(((s/usr/lib64/python2.6/shutil.pyts4          A1  "