B
    \ ,                 @   sl  d Z ddlZddlZddlZddlZddlZejdkZejdkZejdkZ	ejdkZ
ejdkZejdk ZejdkZejd	Zeed
ZejdZe oe ZejZejZejZeZeddddddddgZeddddddddgZyddlZW n ek
r   ddlZY nX er&dd ZneZerTddl Z ddl!Z!ddl"Z"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l*m-Z- ddl#m.Z. ddl/m0Z0m1Z1m2Z2m3Z3m4Z4 efZ5e6fZ7e6Z8eZ9e:fZ;e<Z=e#j>Z?e@ZAeBZCeDe!dZEeDe!dZFeDe!dZGdd  ZHd!d" ZId#d$ ZJd%d& ZKd'd( ZLdYd)d*ZMd+d, ZNd-d. ZOe
rHePZPnd/d0 ZPnPddl Z ddlQZ"ddl#Z#ddl-m-Z- ddlRm-Z, dd1l'mSZT dd2l#mUZ. dd3lVm3Z3 dd4lVm0Z0 dd5lVm4Z4 dd6lVm1Z1 dd7lWm2Z2 yddlXZ$W n ek
r   ddl$Z$Y nX eYfZ5e6fZ7eZ8eZZ9e:e[fZ;d8d9 Z)ePZPeLZLe&Z&e jJZJe jIZIe#j\Z?e#j]ZAe#j^ZCd:d  ZHdZd;d<ZEd=d> Z=d?d@ ZFdAdB ZGdCd, ZNdDd. ZOdEd& ZKdFdG Z_e`dH e	rddIl'maZa ddddJi i edKd dLd dMd dNd eafdOdPZbn(erddQl'mcZd dRdP ZbnddQl'mcZb eser&ejeZfnejZfer@ddlgmhZi nddlZiejdSdT Zjd[dUdVZkdWdX ZldS )\z1Handle Python version/platform incompatibilities.    N)      )r   r   )r      )r      )r   r   )r   r   r   javaZpypy_version_infowinFullArgSpecargsvarargsvarkwdefaults
kwonlyargskwonlydefaultsannotationsc             C   s   | S )N )argr   r   5lib/python3.7/site-packages/sqlalchemy/util/compat.py<lambda>D   s    r   )reduce)getfullargspec)BytesIO)StringIO)zip_longest)
quote_plusunquote_plus	parse_qslquoteunquoteexec
__import__printc             C   s
   |  dS )Nzlatin-1)encode)sr   r   r   bl   s    r#   c             C   s   t | dS )Nascii)base64	b64decoder!   )xr   r   r   r&   o   s    r&   c             C   s   t | dS )Nr$   )r%   	b64encodedecode)r'   r   r   r   r(   r   s    r(   c             C   s   | j |ddS )Nbackslashreplace)errors)r)   )textencodingr   r   r   decode_backslashreplaceu   s    r.   c             C   s   | |k| |k  S )Nr   )ar#   r   r   r   cmpx   s    r0   c             C   s:   |d k	r||k	st d||_|j|k	r2|||d S )NzSame cause emitted)AssertionError	__cause____traceback__with_traceback)tpvaluetbcauser   r   r   reraise{   s    

r9   c             C   s   | S )Nr   )r"   r   r   r   u   s    r:   c             C   s   | S )Nr   )r"   r   r   r   ue   s    r;   c             C   s
   t | dS )N__call__)hasattr)fnr   r   r   callable   s    r?   )
getargspec)izip_longest)r   )r   )r   )r   )r   c             C   s   t t| dd g d i f  S )Nr      )r   _getargspec)funcr   r   r   inspect_getfullargspec   s    rE   c             C   s   | S )Nr   )r"   r   r   r   r#      s    c             C   s   |d krt d nt d d S )Nzexec func_text in globals_zexec func_text in globals_, lcl)r   )Z	func_textglobals_Zlclr   r   r   exec_   s    
rG   c             C   s   dd | D S )Nc             s   s   | ]}t |V  qd S )N)ord).0Zbyter   r   r   	<genexpr>   s    ziterbytes.<locals>.<genexpr>r   )Zbufr   r   r   	iterbytes   s    rK   c              G   s4   t | dkr,| dd dd | d D f } t|  S )NrB   r   r   c             S   s   g | ]}t |qS r   )str)rI   r   r   r   r   
<listcomp>   s    zimport_.<locals>.<listcomp>)lenr   )r	   r   r   r   import_   s     rO   c              O   sL   | dtj}|d krd S x,t| D ] }t|ts:t|}|| q$W d S )Nfile)popsysstdout	enumerate
isinstance
basestringrL   write)r	   kwargsfpr   r   r   r   print_   s    
rZ   c             C   s
   t | dS )Nzutf-8)unicode)r"   r   r   r   r:      s    c             C   s
   t | dS )NZunicode_escape)r[   )r"   r   r   r   r;      s    c             C   s4   y
|  |S  tk
r.   t| dd   S X d S )N   )r)   UnicodeDecodeErrorrepr)r,   r-   r   r   r   r.      s    
c             C   s<   t | tst| jdddS t | tr4| jdddS | S d S )Nr$   r*   )r+   )rU   string_typesr[   r!   )r,   r   r   r   safe_bytestring   s
    

ra   zdef reraise(tp, value, tb=None, cause=None):
    if cause is not None:
        assert cause is not value, 'Same cause emitted'
    raise tp, value, tb
)formatannotationr   c             C   s   d|  S )N*r   )namer   r   r   r     s    c             C   s   d|  S )Nz**r   )rd   r   r   r   r     s    c             C   s   dt |  S )N=)r_   )r6   r   r   r   r     s    c             C   s   d|  S )Nz -> r   )r,   r   r   r   r     s    c                s(   fdd}g }|r(t | t | }xFt| D ]:\}}||}|rb||krb||
|||   }|| q2W |dk	r|||| n|r|d |rx:|D ]2}||}|r||kr||
|| 7 }|| qW |dk	r||	|| dd| d }d kr$|| d 7 }|S )	aa  Copy formatargspec from python 3.7 standard library.

        Python 3 has deprecated formatargspec and requested that Signature
        be used instead, however this requires a full reimplementation
        of formatargspec() in terms of creating Parameter objects and such.
        Instead of introducing all the object-creation overhead and having
        to reinvent from scratch, just copy their compatibility routine.

        Utimately we would need to rewrite our "decorator" routine completely
        which is not really worth it right now, until all Python 2.x support
        is dropped.

        c                s(   | }|  kr$|d |   7 }|S )Nz: r   )r   result)r   rb   	formatargr   r   formatargandannotation  s    z5inspect_formatargspec.<locals>.formatargandannotationNrc   (z, )return)rN   rT   appendjoin)r	   r
   r   r   r   r   r   rg   ZformatvarargsZformatvarkwZformatvalueZformatreturnsrb   rh   ZspecsZfirstdefaultir   specZ	kwonlyargrf   r   )r   rb   rg   r   inspect_formatargspec   s2    


rp   )formatargspecc              O   s   t | dd |S )Nr   rB   )_inspect_formatargspec)ro   kwr   r   r   rp   A  s    c              g   s   g }g }d}zTy:x.| D ]&}|j }|j}||  || qW |V  W n   t }Y nX W dx6|r| }y|| r~d}W qd   t }Y qdX qdW |dkrt|d |d |d  X dS )zImplement contextlib.nested, mostly for unit tests.

    As tests still need to run on py2.6 we can't use multiple-with yet.

    Function is removed in py3k but also emits deprecation warning in 2.7
    so just roll it here for everyone.

    )NNNNr   r\   r   )__exit__	__enter__rl   rR   exc_inforQ   r9   )ZmanagersZexitsZvars_excZmgrZexit_Zenterr   r   r   nestedW  s*    

rx   c             C   sB   |d krt  }|\}}}|| k	r&|nd }tt| | ||d d S )N)r7   r8   )rR   rv   r9   type)Z	exceptionrv   exc_type	exc_valueZexc_tbr8   r   r   r   raise_from_causez  s
    
r|   c                s"   G  fddd}|ddi S )zCreate a base class with a metaclass.

    Drops the middle class upon creation.

    Source: http://lucumr.pocoo.org/2013/5/21/porting-to-python-3-redux/

    c                   s&   e Zd ZejZejZ fddZdS )z!with_metaclass.<locals>.metaclassc                s$   |d krt | |d|S | |S )Nr   )ry   __new__)clsrd   Z
this_basesd)basesmetar   r   r}     s    z)with_metaclass.<locals>.metaclass.__new__N)__name__
__module____qualname__ry   r<   __init__r}   r   )r   r   r   r   	metaclass  s   r   Ztemporary_classNr   )r   r   r   r   )r   r   r   with_metaclass  s    		r   )NN)N)N)m__doc__collections
contextliboperatorrR   Ztimeversion_infoZpy36Zpy33Zpy35Zpy32Zpy3kZpy2kZpy265platform
startswithZjythonr=   ZpypyZwin32Zcpythoncontextmanager
attrgetterZdottedgetter
namedtuplenextr   Z	threadingImportErrorZdummy_threadingZ
safe_kwargrL   r%   builtinsZconfigparser	itertoolspickle	functoolsr   inspectr   rE   ior   Zbyte_bufferr   r   Zurllib.parser   r   r   r   r   r`   bytesZbinary_typesZbinary_typeZ	text_typeintZ	int_typesiterrK   filterfalseZitertools_filterfalsefilterZitertools_filtermapZitertools_imapgetattrrG   rO   rZ   r#   r&   r(   r.   r0   r9   r:   r;   r?   ZConfigParserZ	cStringIOr@   rC   rA   ZurllibZurlparseZcPicklerV   r[   ZlongZifilterfalseZifilterZimapra   r   rb   rp   rq   rr   ZclockZ	time_funcZcollections.abcabcZcollections_abcrx   r|   r   r   r   r   r   <module>   s(  













		5
#
