
"þîhu  ã               @   sÅ   d  d l  Z  d  d l Z d  d l m Z d d l m Z d d l m Z d d „  Z d d	 „  Z	 d
 d „  Z
 e j e e d d d � „ Z e j e e d d d d � „ Z Gd d „  d e ƒ Z d S)é    N)ÚRawConfigParseré   )Úpy39)ÚSetuptoolsDeprecationWarningc             C   sl   t  |  t ƒ r t j d |  ƒ Sy4 |  j d ƒ }  t j d |  ƒ }  |  j d ƒ }  Wn t k
 rg Yn X|  S)NZNFDzutf-8)Ú
isinstanceÚstrÚunicodedataÚ	normalizeÚdecodeÚencodeÚUnicodeError)Úpath© r   ú>/tmp/pip-build-zijwfla7/setuptools/setuptools/unicode_utils.pyÚ	decompose
   s    r   c             C   so   t  |  t ƒ r |  St j ƒ  p" d } | d f } x7 | D]/ } y |  j | ƒ SWq8 t k
 rf w8 Yq8 Xq8 Wd S)z]
    Ensure that the given path is decoded,
    ``None`` when no expected encoding works
    zutf-8N)r   r   ÚsysÚgetfilesystemencodingr
   ÚUnicodeDecodeError)r   Zfs_encÚ
candidatesÚencr   r   r   Úfilesys_decode   s    r   c             C   s.   y |  j  | ƒ SWn t k
 r) d SYn Xd S)z/turn unicode encoding into a functional routineN)r   ÚUnicodeEncodeError)Ústringr   r   r   r   Ú
try_encode+   s    r   )ÚfileÚreturnc             C   s…   y- t  |  d d d ƒ� } | j ƒ  SWd QRXWnQ t k
 r€ t j d |  d | ƒ t  |  d d | ƒ� } | j ƒ  SWd QRXYn Xd S)a
  
    First try to read the file with UTF-8, if there is an error fallback to a
    different encoding ("locale" by default). Returns the content of the file.
    Also useful when reading files that might have been produced by an older version of
    setuptools.
    ÚrÚencodingzutf-8Nr   Úfallback_encoding)ÚopenÚreadr   Ú_Utf8EncodingNeededÚemit)r   r   Úfr   r   r   Ú_read_utf8_with_fallback3   s    r$   )Úcfgr   r   c             C   sc   y |  j  | d d ƒWnE t k
 r^ t j d | d | ƒ |  j ƒ  |  j  | d | ƒYn Xd S)z“Same idea as :func:`_read_utf8_with_fallback`, but for the
    :meth:`RawConfigParser.read` method.

    This method may call ``cfg.clear()``.
    r   zutf-8r   r   N)r    r   r!   r"   Úclear)r%   r   r   r   r   r   Ú_cfg_read_utf8_with_fallbackC   s    
r'   c               @   s   e  Z d  Z d Z d Z d S)r!   zZ
    `encoding="utf-8"` fails with {file!r}, trying `encoding={fallback_encoding!r}`.
    aÚ  
    Fallback behavior for UTF-8 is considered **deprecated** and future versions of
    `setuptools` may not implement it.

    Please encode {file!r} with "utf-8" to ensure future builds will succeed.

    If this file was produced by `setuptools` itself, cleaning up the cached files
    and re-building/re-installing the package with a newer version of `setuptools`
    (e.g. by updating `build-system.requires` in its `pyproject.toml`)
    might solve the problem.
    N)Ú__name__Ú
__module__Ú__qualname__Z_SUMMARYZ_DETAILSr   r   r   r   r!   S   s   r!   )r   r   Úconfigparserr   Úcompatr   Úwarningsr   r   r   r   ZLOCALE_ENCODINGr   r$   r'   r!   r   r   r   r   Ú<module>   s   