
§|j@  ã            0   @   s¿  d  Z  d d l m Z m Z d d l Z d d l Z d d l m Z y d d l m	 Z
 Wn" e k
 r| d d l m	 Z
 Yn Xy d d l m Z Wn" e k
 rµ d d l m Z Yn Xy d d l Z Wn_ e k
 r'y d d l m Z Wn6 e k
 r"d d l Z e j e _ e j e _ Yn XYn Xy d d l Z d d	 „  Z Wn. e k
 rtd d
 l m Z d d	 „  Z Yn Xd d d d d d d d d d g
 Z e j d. k rÁd Z d d l m Z n3 d d l Z e  e d ƒ Z e rîe j Z n d Z e j d/ k r!d d „  Z! d d d „ Z" n d d „  Z! d d d „ Z" d  d! „  Z# d" d „  Z$ d# d$ „  Z% d0 Z& e j d1 k re& d2 7Z& e j' j( d* ƒ p¬e j' d+ k o¬e j) d, k Z* d- d „  Z+ d S)3zKStuff that differs in different Python versions and platform
distributions.é    )Úabsolute_importÚdivisionN)Ú	text_type)Ú
dictConfig)ÚOrderedDict)Ú	ipaddressc              C   s1   t  j d ƒ t  j d ƒ g }  t t t |  ƒ ƒ S)NÚstdlibÚ
platstdlib)Ú	sysconfigÚget_pathÚsetÚfilterÚbool)Úpaths© r   ú2/tmp/pip-build-5c7ija6t/pip/pip/compat/__init__.pyÚ
get_stdlib"   s    r   )r
   c              C   s=   t  j d d ƒ t  j d d d d ƒ g }  t t t |  ƒ ƒ S)NÚstandard_libTÚplat_specific)r
   Úget_python_libr   r   r   )r   r   r   r   r   +   s    Úlogging_dictConfigr   Úuses_pycacheÚconsole_to_strÚ
native_strÚget_path_uidÚstdlib_pkgsÚWINDOWSÚsamefiler   é   é   T)Úcache_from_sourcer    c             C   s=   y |  j  t j j ƒ SWn t k
 r8 |  j  d ƒ SYn Xd  S)NÚutf_8)ÚdecodeÚsysÚ
__stdout__ÚencodingÚUnicodeDecodeError)Úsr   r   r   r   G   s    Fc             C   s/   t  |  t ƒ r+ |  j d | r$ d n d ƒ S|  S)Nzutf-8ÚreplaceÚstrict)Ú
isinstanceÚbytesr"   )r'   r(   r   r   r   r   M   s    c             C   s   |  S)Nr   )r'   r   r   r   r   S   s    c             C   s    t  |  t ƒ r |  j d ƒ S|  S)Nzutf-8)r*   r   Úencode)r'   r(   r   r   r   r   V   s    c             C   sH   t  |  d ƒ r |  j ƒ  S|  j |  j |  j d d d } | d Sd  S)NÚtotal_secondsé   i  é
   é   i@B i@B )Úhasattrr-   ÚmicrosecondsÚsecondsÚdays)ÚtdÚvalr   r   r   r-   ]   s    
#r-   c             C   sˆ   t  t d ƒ rM t j |  t j t j Bƒ } t j | ƒ j } t j | ƒ n7 t j j	 |  ƒ st t j
 |  ƒ j } n t d |  ƒ ‚ | S)a)  
    Return path's uid.

    Does not follow symlinks:
        https://github.com/pypa/pip/pull/935#discussion_r5307003

    Placed this function in compat due to differences on AIX and
    Jython, that should eventually go away.

    :raises OSError: When path is a symlink or can't be read.
    Ú
O_NOFOLLOWz1%s is a symlink; Will not return uid for symlinks)r1   ÚosÚopenÚO_RDONLYr7   ÚfstatÚst_uidÚcloseÚpathÚislinkÚstatÚOSError)r>   ÚfdÚfile_uidr   r   r   r   e   s    c             C   sD   t  j j |  ƒ } |  j d ƒ r@ | j d ƒ r@ | d d … } | S)zl
    Expand ~ and ~user constructions.

    Includes a workaround for http://bugs.python.org/issue14768
    z~/z//é   N)r8   r>   Ú
expanduserÚ
startswith)r>   Úexpandedr   r   r   rE   ‚   s    rE   ÚpythonÚwsgirefé   é   ÚargparseÚwinÚcliÚntc             C   so   t  t j d ƒ r% t j j |  | ƒ St j j t j j |  ƒ ƒ } t j j t j j | ƒ ƒ } | | k Sd S)z>Provide an alternative for os.path.samefile on Windows/Python2r   N)r1   r8   r>   r   ÚnormcaseÚabspath)Úfile1Úfile2Úpath1Úpath2r   r   r   r   �   s
    )r   r   )r   )rH   rI   )rJ   rK   )rL   ),Ú__doc__Ú
__future__r   r   r8   r#   Zpip._vendor.sixr   Úlogging.configr   r   ÚImportErrorZpip.compat.dictconfigÚcollectionsr   Zpip._vendor.ordereddictr   Úpip._vendorÚipaddrZ	IPAddressÚ
ip_addressZ	IPNetworkÚ
ip_networkr
   r   Ú	distutilsÚ__all__Úversion_infor   Úimportlib.utilr    Úimpr1   r   r   r-   r   rE   r   ÚplatformrF   Únamer   r   r   r   r   r   Ú<module>   sh   		
