U
    KQh@                     @   s   d Z ddlmZmZ ddlZddlZddlmZ zddlm	Z
 W n  ek
r`   ddlm	Z
 Y nX zddlmZ W n  ek
r   ddlmZ Y nX zddlZW nR ek
r   z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 z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rejZndZejdkrdd Z!d,ddZ"ndd Z!d-ddZ"d d! Z#d"d Z$d#d$ Z%d%Z&ejd&kre&d'7 Z&ej'(d(pej'd)koej)d*kZ*d+d Z+dS ).zKStuff that differs in different Python versions and platform
distributions.    )absolute_importdivisionN)	text_type)
dictConfig)OrderedDict)	ipaddressc                  C   s"   t dt dg} ttt| S )Nstdlib
platstdlib)	sysconfigget_pathsetfilterboolpaths r   2/tmp/pip-build-tlro1kwj/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!   )r   c                 C   s4   z|  tjjW S  tk
r.   |  d Y S X d S )Nutf_8)decodesys
__stdout__encodingUnicodeDecodeErrorsr   r   r   r   G   s    Fc                 C   s"   t | tr| d|rdndS | S )N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| dS | S )Nr*   )r-   r   encoder/   r   r   r   r   V   s    

c                 C   s<   t | dr|  S | j| j| jd d  d  }|d S d S )Ntotal_seconds   i  i@B )hasattrr1   microsecondssecondsdays)tdvalr   r   r   r1   ]   s    
r1   c                 C   s`   t tdr6t| tjtjB }t|j}t| n&tj	| sPt
| 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)r3   osopenO_RDONLYr9   fstatst_uidclosepathislinkstatOSError)r@   fdfile_uidr   r   r   r   e   s    
c                 C   s0   t j| }| dr,|dr,|dd }|S )zl
    Expand ~ and ~user constructions.

    Includes a workaround for http://bugs.python.org/issue14768
    z~/z//   N)r:   r@   
expanduser
startswith)r@   expandedr   r   r   rG      s    rG   )pythonwsgiref)      )argparsewinclintc                 C   sN   t tjdrtj| |S tjtj| }tjtj|}||kS dS )z>Provide an alternative for os.path.samefile on Windows/Python2r   N)r3   r:   r@   r   normcaseabspath)file1file2path1path2r   r   r   r      s
    )F)F),__doc__
__future__r   r   r:   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!   impr3   r   r   r1   r   rG   r   platformrH   namer   r   r   r   r   r   <module>   sz   	       

