
"þîh*  ã               @   s  d  Z  d d l Z d d l Z d d l m Z m Z d d l m Z d d l m	 Z	 y d d l m
 Z
 Wn- e k
 r— e e d d d	 d
 � „  Z
 Yn Xe d ƒ Z d d „  Z e d e f e e e d d d � „  Z d e d d „ Z d d „  Z d d „  Z d S)z2Convenience layer on top of stdlib's shutil and osé    N)ÚCallableÚTypeVaré   )Úpy311)Úlog)Úchmod)ÚargsÚkwargsÚreturnc              O   s   d  S)N© )r   r	   r   r   ú8/tmp/pip-build-zijwfla7/setuptools/setuptools/_shutil.pyr      s    r   Ú_Tc             C   s`   t  j d |  | ƒ y t |  | ƒ Wn5 t k
 r[ } z t  j d | ƒ WYd  d  } ~ Xn Xd  S)Nzchanging mode of %s to %ozchmod failed: %s)r   Údebugr   ÚOSError)ÚpathÚmodeÚer   r   r   Úattempt_chmod_verbose   s
    r   .)ÚfuncÚargÚexcr
   c             C   sK   |  t  j t  j g k rA t  j d k rA t | t j ƒ |  | ƒ S| ‚ d S)zIshutils onexc callback to automatically call chmod for certain functions.ÚntN)ÚosÚunlinkÚremoveÚnamer   ÚstatÚS_IWRITE)r   r   r   r   r   r   Ú_auto_chmod    s    '
r   Fc             C   s   t  j |  | | ƒ S)zx
    Similar to ``shutil.rmtree`` but automatically executes ``chmod``
    for well know Windows failure scenarios.
    )r   Zshutil_rmtree)r   Úignore_errorsZonexcr   r   r   Úrmtree+   s    r    c             K   s#   t  j j |  ƒ r t |  | � d  S)N)r   r   Úisdirr    )r   Úoptsr   r   r   Úrmdir3   s    r#   c              C   s    t  j d ƒ }  t  j |  ƒ |  S)Né   )r   Úumask)Útmpr   r   r   Úcurrent_umask8   s    r'   )Ú__doc__r   r   Ztypingr   r   Úcompatr   Ú	distutilsr   r   ÚImportErrorÚobjectr   r   ÚstrÚBaseExceptionr   r    r#   r'   r   r   r   r   Ú<module>   s     
	