
§|jË  ã               @   s�   d  d l  Z  d  d l Z d  d l Z e  j d f e  j d f e  j d f e  j d f e  j d f e  j d f e  j	 d f g Z
 e j d	 ƒ Z d
 d „  Z d S)é    NÚutf8Úutf16zutf16-bezutf16-leÚutf32zutf32-bezutf32-les   coding[:=]\s*([-\w.]+)c             C   sÑ   x@ t  D]8 \ } } |  j | ƒ r |  t | ƒ d … j | ƒ Sq Wxu |  j d ƒ d d … D]Z } | d d … d k r] t j | ƒ r] t j | ƒ j ƒ  d j d ƒ } |  j | ƒ Sq] W|  j t j	 d ƒ ƒ S)	zŠCheck a bytes string for a BOM to correctly detect the encoding

    Fallback to locale.getpreferredencoding(False) like open() on Python3Ns   
é   r   é   ó   #ÚasciiF)
ÚBOMSÚ
startswithÚlenÚdecodeÚsplitÚENCODING_REÚsearchÚgroupsÚlocaleÚgetpreferredencoding)ÚdataÚbomÚencodingÚline© r   ú1/tmp/pip-build-5c7ija6t/pip/pip/utils/encoding.pyÚauto_decode   s    ! %"r   )Úcodecsr   ÚreÚBOM_UTF8Ú	BOM_UTF16ÚBOM_UTF16_BEÚBOM_UTF16_LEÚ	BOM_UTF32ÚBOM_UTF32_BEÚBOM_UTF32_LEr	   Úcompiler   r   r   r   r   r   Ú<module>   s   