³ò
™›\Kc           @   sç   d  Z  d d k Z d d k Z d d k Z d d k l Z d d d d d d	 d
 d d d g
 Z d e f d „  ƒ  YZ d d „ Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z d „  Z e d „ Z e d d „ Z d „  Z d „  Z d S(   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(   t   abspatht   copyfileobjt   copyfilet   copymodet   copystatt   copyt   copy2t   copytreet   movet   rmtreet   Errorc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s   /usr/lib/python2.5/shutil.pyR
      s   i   i   c         C   s2   x+ |  i  | ƒ } | p Pn | i | ƒ q d S(   s=   copy data from file-like object fsrc to file-like object fdstN(   t   readt   write(   t   fsrct   fdstt   lengtht   buf(    (    s   /usr/lib/python2.5/shutil.pyR      s
    c         C   s‚   t  t i d ƒ o5 y t i i |  | ƒ SWqH t j
 o t SqH Xn t i i t i i |  ƒ ƒ t i i t i i | ƒ ƒ j S(   Nt   samefile(   t   hasattrt   ost   pathR   t   OSErrort   Falset   normcaseR    (   t   srct   dst(    (    s   /usr/lib/python2.5/shutil.pyt	   _samefile   s    c         C   s”   t  |  | ƒ o t d |  | f ‚ n d } d } z/ t |  d ƒ } t | d ƒ } t | | ƒ Wd | o | i ƒ  n | o | i ƒ  n Xd S(   s   Copy data from src to dsts   `%s` and `%s` are the same filet   rbt   wbN(   R   R
   t   Nonet   openR   t   close(   R   R   R   R   (    (    s   /usr/lib/python2.5/shutil.pyR   &   s    c         C   sI   t  t d ƒ o5 t i |  ƒ } t i | i ƒ } t i | | ƒ n d S(   s   Copy mode bits from src to dstt   chmodN(   R   R   t   statt   S_IMODEt   st_modeR"   (   R   R   t   stt   mode(    (    s   /usr/lib/python2.5/shutil.pyR   7   s    c         C   sy   t  i |  ƒ } t i | i ƒ } t t  d ƒ o  t  i | | i | i f ƒ n t t  d ƒ o t  i | | ƒ n d S(   s?   Copy all stat info (mode bits, atime and mtime) from src to dstt   utimeR"   N(	   R   R#   R$   R%   R   R(   t   st_atimet   st_mtimeR"   (   R   R   R&   R'   (    (    s   /usr/lib/python2.5/shutil.pyR   >   s     c         C   sV   t  i i | ƒ o% t  i i | t  i i |  ƒ ƒ } n t |  | ƒ t |  | ƒ d S(   sV   Copy data and mode bits ("cp src dst").

    The destination may be a directory.

    N(   R   R   t   isdirt   joint   basenameR   R   (   R   R   (    (    s   /usr/lib/python2.5/shutil.pyR   H   s    %c         C   sV   t  i i | ƒ o% t  i i | t  i i |  ƒ ƒ } n t |  | ƒ t |  | ƒ d S(   s]   Copy data and all stat info ("cp -p src dst").

    The destination may be a directory.

    N(   R   R   R+   R,   R-   R   R   (   R   R   (    (    s   /usr/lib/python2.5/shutil.pyR   S   s    %c         C   s¦  t  i |  ƒ } t  i | ƒ g  } x| D]
} t  i i |  | ƒ } t  i i | | ƒ } yu | o6 t  i i | ƒ o# t  i | ƒ } t  i | | ƒ n5 t  i i | ƒ o t	 | | | ƒ n t
 | | ƒ Wq) t t  i f j
 o% }	 | i | | t |	 ƒ f ƒ q) t j
 o }
 | i |
 i d ƒ q) Xq) Wy t |  | ƒ WnC t j
 o n2 t j
 o% }	 | i |  | t |	 ƒ f ƒ n X| o t | ‚ n d S(   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.

    i    N(   R   t   listdirt   makedirsR   R,   t   islinkt   readlinkt   symlinkR+   R   R   t   IOErrort   errort   appendt   strR
   t   extendt   argsR   t   WindowsErrorR   (   R   R   t   symlinkst   namest   errorst   namet   srcnamet   dstnamet   linktot   whyt   err(    (    s   /usr/lib/python2.5/shutil.pyR   _   s4      !c         C   s†  | o d „  } n | d j o d „  } n g  } y t i |  ƒ } Wn1 t i j
 o" } | t i |  t i ƒ  ƒ n XxÁ | D]¹ } t i i |  | ƒ } y t i | ƒ i	 } Wn t i j
 o d } n Xt
 i | ƒ o t | | | ƒ q‚ y t i | ƒ Wq‚ t i j
 o" } | t i | t i ƒ  ƒ q‚ Xq‚ Wy t i |  ƒ Wn/ t i j
 o  | t i |  t i ƒ  ƒ n Xd S(   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.

    c          W   s   d  S(   N(    (   R8   (    (    s   /usr/lib/python2.5/shutil.pyt   onerror˜   s    c          W   s   ‚  d  S(   N(    (   R8   (    (    s   /usr/lib/python2.5/shutil.pyRC   ›   s    i    N(   R   R   R.   R4   t   syst   exc_infoR   R,   t   lstatR%   R#   t   S_ISDIRR	   t   removet   rmdir(   R   t   ignore_errorsRC   R;   RB   R=   t   fullnameR'   (    (    s   /usr/lib/python2.5/shutil.pyR	   Œ   s4     "c         C   s£   y t  i |  | ƒ Wnˆ t j
 o| t  i i |  ƒ oH t |  | ƒ o t d |  | f ‚ n t |  | d t ƒt	 |  ƒ qŸ t
 |  | ƒ t  i |  ƒ n Xd S(   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(   R   t   renameR   R   R+   t	   destinsrcR
   R   t   TrueR	   R   t   unlink(   R   R   (    (    s   /usr/lib/python2.5/shutil.pyR   ´   s    
c         C   s   t  | ƒ i t  |  ƒ ƒ S(   N(   R    t
   startswith(   R   R   (    (    s   /usr/lib/python2.5/shutil.pyRM   Ê   s    i @  (   t   __doc__R   RD   R#   t   os.pathR    t   __all__t   EnvironmentErrorR
   R   R   R   R   R   R   R   R   R   R   R	   R   RM   (    (    (    s   /usr/lib/python2.5/shutil.pys   <module>   s$   				
		-(	