
    ?d                     X   d Z ddlZddlZddlZddlZej
                  d   dk\  Zej
                  d   dk\  xr ej
                  d   dk\  Zej
                  d   dk\  xr ej
                  d   dk\  Zej
                  d   dk\  xr ej
                  d   dk\  Z	ernej                  Z
ej                  ZddlZddZddlZej                  ZeZeZd	 ZddlZej(                  j*                  ZddlZej0                  Zej2                  Zn|ddlZddlZdd
lmZ ej                  xZ
Zej:                  ZddZeZeZddlZej(                  j>                  Zddl mZ ej0                  Zddl!Z! G d d e!jD                  dd            ZddZ#ere$Z%e$Z&ne%Z%d Z& G d dej(                        Zd Z'y)z.Utilities for Python2 / Python3 compatibility.    N               c                 2    t        j                  | ||      S )N)modeencoding)codecsopen)filenamer	   r
   newlines       8/usr/lib/python3/dist-packages/yapf/yapflib/py3compat.pyopen_with_encodingr       s    ;;xdX>>    c                      t        j                  t        j                  j                  d      } | j                  j
                  j                         j                  d      S )Nutf-8)r
   )ioTextIOWrappersysstdinbufferrawreadalldecode)wrappers    r   	raw_inputr   )   sB    syy//'BG>>%%'..w77r   )ifilterc                     d }|S )Nc                     | S N )user_functions    r   fake_wrapperzlru_cache.<locals>.fake_wrapperB   s    r   r"   )maxsizetypedr$   s      r   	lru_cacher'   @   s     r   )tokenizec                       e Zd Zy)	TokenInfoN)__name__
__module____qualname__r"   r   r   r*   r*   S   s    r   r*   ztype string start end linec                 "   t         r9t        j                  j                  j	                  | j                  |             yt        j                  dk(  rddl}t        j                  t        j                  u r<|j                  t        j                  j                         t        j                         t        j                  j	                  | j                  |             yt        j                  j	                  | j                  |             y)aI  Encode the given string and emit to stdout.

  The string may contain non-ascii characters. This is a problem when stdout is
  redirected, because then Python doesn't know the encoding and we may get a
  UnicodeEncodeError.

  Arguments:
    s: (string) The string to encode.
    encoding: (string) The encoding of the string.
  win32r   N)PY3r   stdoutr   writeencodeplatformmsvcrt
__stdout__setmodefilenoosO_BINARY)sr
   r5   s      r   EncodeAndWriteToStdoutr<   X   s     	JJAHHX./
||w 
~~#nnSZZ&&("++6JJQXXh'(JJQXXh'(r   c                 .    t        j                  | d      S )z!Force conversion of s to unicode.r   )__builtin__unicode)r;   s    r   r?   r?   {   s    q'**r   c                       e Zd ZesddZyy)ConfigParserNc                 *    | j                  ||       y )N)r   )readfp)selffpsources      r   	read_filezConfigParser.read_file   s    
kk"vk&r   r!   )r+   r,   r-   r0   rG   r"   r   r   rA   rA      s    	' 
r   rA   c                     t         j                  }t        r|j                  d      }| j	                  |      r| t        |      d S | S )z>Remove any Byte-order-Mark bytes from the beginning of a file.r   N)r   BOM_UTF8r0   r   
startswithlen)rF   boms     r   	removeBOMrM      s@    #
**W
Cs#c()	-r   ) )   F)r   )(__doc__r   r   r9   r   version_infor0   PY36PY37PY38StringIOBytesIOr   	functoolsr'   rangefilterr   r   configparserrA   BOOLEAN_STATESCONFIGPARSER_BOOLEAN_STATESr(   detect_encodingr*   r>   	cStringIO	itertoolsr   xrange_boolean_stateslib2to3.pgen2collections
namedtupler<   str
basestringr?   rM   r"   r   r   <module>rg      s   5  	 	 
	qQ
a<C$4$4Q$71$<
a<C$4$4Q$71$<
a<C$4$4Q$71$<[[(JJ'? !!)
%'8  !- 9 9 H H,,/  ) )))(Www %)% , 9 9 I I$,,/	k[*FG	
): *'*+'<,, 'r   