3
zYði@  ã            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
 W n  ek
r`   ddlm	Z
 Y nX yddlmZ W n  ek
r’   ddlmZ Y nX yddlZW nR ek
rò   yddlmZ W n, ek
rì   ddlZeje_eje_Y nX Y nX yddlZdd	„ ZW n* ek
�r2   dd
lmZ dd	„ ZY nX ddddddddddg
Zejd.k�rjdZddlmZ n$ddlZe edƒZe�rŠejZndZejd/k�r®dd„ Z!d0dd„Z"ndd„ Z!d1dd„Z"d d!„ Z#d"d„ Z$d#d$„ Z%d2Z&ejd3k�rðe&d47 Z&ej'j(d*ƒ�pej'd+k�oej)d,kZ*d-d„ Z+dS )5zKStuff that differs in different Python versions and platform
distributions.é    )Úabsolute_importÚdivisionN)Ú	text_type)Ú
dictConfig)ÚOrderedDict)Ú	ipaddressc              C   s"   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-ue6tjl93/pip/pip/compat/__init__.pyÚ
get_stdlib"   s    r   )r
   c              C   s(   t jdd�t jddd�g} ttt| ƒƒS )NT)Ústandard_lib)r   Ú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ƒS  tk
r(   | j dƒS X d 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   s<   t | dƒr| jƒ S | j| j| jd d  d  }|d S d 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ƒr6tj| tjtjB ƒ}tj|ƒj}tj|ƒ n&tjj	| ƒsPt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   s0   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   sN   t tjdƒrtjj| |ƒS tjjtjj| ƒƒ}tjjtjj|ƒƒ}||kS d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   )F)F)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   	


