B
    ãUvgì  ã               @   sR   d dl Z d dlZd dlZd dlmZ dd„ Zdd„ Zdd„ Ze d	¡Z	d
d„ Z
dS )é    N)Úsixc             C   sV   t | tjƒrt d| ¡S y$|  d¡} t d| ¡} |  d¡} W n tk
rP   Y nX | S )NZNFDzutf-8)Ú
isinstancer   Ú	text_typeÚunicodedataÚ	normalizeÚdecodeÚencodeÚUnicodeError)Úpath© r   ú@/tmp/pip-install-r_9ig3yj/setuptools/setuptools/unicode_utils.pyÚ	decompose	   s    
r   c          	   C   sX   t | tjƒr| S t ¡ pd}|df}x.|D ]&}y
|  |¡S  tk
rN   w*Y q*X q*W dS )zY
    Ensure that the given path is decoded,
    NONE when no expected encoding works
    zutf-8N)r   r   r   ÚsysÚgetfilesystemencodingr   ÚUnicodeDecodeError)r
   Zfs_encÚ
candidatesÚencr   r   r   Úfilesys_decode   s    

r   c             C   s$   y
|   |¡S  tk
r   dS X dS )z/turn unicode encoding into a functional routineN)r   ÚUnicodeEncodeError)Ústringr   r   r   r   Ú
try_encode(   s    
r   s&   ^[ \t\f]*#.*?coding[:=][ \t]*([-\w.]+)c             C   s8   |   ¡ }|  d¡ t |¡}|d kr(d S | d¡ d¡S )Nr   é   Úascii)ÚreadlineÚseekÚ	CODING_REÚmatchÚgroupr   )ÚfpÚ
first_lineÚmr   r   r   Údetect_encoding3   s    

r!   )r   r   ÚreZsetuptools.externr   r   r   r   Úcompiler   r!   r   r   r   r   Ú<module>   s   
