��
���Lc@s8dZddkZddkZddkZddklZddkZddkZdddddd d
ddd
g
Zd
e fd��YZ
yeWnej
o
dZnXdd�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(tabspathtcopyfileobjtcopyfiletcopymodetcopystattcopytcopy2tcopytreetmovetrmtreetErrorcBseZRS((t__name__t
__module__(((s/usr/lib/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/lib/python2.6/shutil.pyRs
cCsttid�o2ytii||�SWqEtj
otSXntiitii|��tiitii|��jS(Ntsamefile(thasattrtostpathRtOSErrortFalsetnormcaseR(tsrctdst((s/usr/lib/python2.6/shutil.pyt _samefile!s
cCs�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/lib/python2.6/shutil.pyR-s
&&cCsIttd�o5ti|�}ti|i�}ti||�ndS(sCopy mode bits from src to dsttchmodN(RRtstattS_IMODEtst_modeR$(RRtsttmode((s/usr/lib/python2.6/shutil.pyR6scCs�ti|�}ti|i�}ttd�o ti||i|if�nttd�oti||�nttd�ont|d�o^yti ||i
�Wq�tj
o4}ttd�p|iti
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/lib/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/lib/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/lib/python2.6/shutil.pyRWs%
cs�fd�}|S(s�Function 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/lib/python2.6/shutil.pyt_ignore_patternsgs
((R<R=((R<s/usr/lib/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
R5targsRRtWindowsErrort
isinstance(
RRtsymlinkstignoreR9R:terrorstnametsrcnametdstnametlinktoR1terr((s/usr/lib/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}nXti
|�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/lib/python2.6/shutil.pytonerror�scWs�dS(N((RI((s/usr/lib/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/lib/python2.6/shutil.pyR �s@
"cCstii|itii��S(N(RRR4trstriptsep(R((s/usr/lib/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/lib/python2.6/shutil.pyR�s
cCsyt|�}t|�}|itii�p|tii7}n|itii�p|tii7}n|i|�S(N(RtendswithRRR^t
startswith(RR((s/usr/lib/python2.6/shutil.pyRbsi@(t__doc__RRUR%tos.pathRR6R0t__all__tEnvironmentErrorR
RJt NameErrorR@RRRRRRRR>RRR R_RRb(((s/usr/lib/python2.6/shutil.pyt<module>s4 A1 "