o
    [hB                     @   s  d Z ddl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jdZe oYe Zde  v ZejZejZejZeZedg dZzddlZW n e y   ddl!ZY nw erdd Z"ne#Z"dd Z$er%d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(m0Z0 ddl1m2Z2m3Z3m4Z4m5Z5m6Z6 e#fZ7e8fZ9e8Z:e#Z;e<fZ=e>Z?e(j@ZAeBZCeDZEeFe&dZGeFe&dZHeFe&dZIdd ZJdd ZKd d! ZLd"d# ZMd$d% ZN	&d]d'd(ZOd)d* ZPd+d, ZQer eRZRnd-d. ZRnddl%Z%ddlSZ'ddl(Z(ddl/m/Z/ ddlTm/Z. dd/l(mUZ0 dd0lVm5Z5 dd1lVm2Z2 dd2lVm6Z6 dd3lVm3Z3 dd4lWm4Z4 zddlXZ)W n e yu   ddl)Z)Y nw eYfZ7e8fZ9e#Z:eZZ;e<e[fZ=eRZReNZNe+Z+e%jLZLe%jKZKe(j\ZAe(j]ZCe(j^ZEd5d ZJd^d6d7ZGd8d9 Z?d:d; ZHd<d= ZId>d* ZPd?d, ZQd@d# ZMdAdB Z_e`dC e
rd^dDdEZaddddFi i e#dGd dHd dId dJd eafdKdLZbnerddMlmcZd dNdL ZbnddMlmcZb e	rddlemfZg nddlZgejdOdP Zhd^dQdRZid_dSdTZjdUdV Zker&ddWllmmZm dS ddXllmlZl ddYllmnZn ddZllmoZo G d[d\ d\eoZmemendem_pdS )`z1Handle Python version/platform incompatibilities.    N)      )r   r   )r      )r      )r   r   )r   r   r   javapypy_version_infowindarwinZaarchFullArgSpec)argsvarargsvarkwdefaults
kwonlyargskwonlydefaultsannotationsc                 C      | S N )argr   r   }/home/ubuntu/experiments/live_experiments/Pythonexperiments/Otree/venv/lib/python3.10/site-packages/sqlalchemy/util/compat.py<lambda><   s    r   c           	      C   s   t | r| j} t | std| | j}t |s#td||j}|j	}t
r.|jnd}t|d| }t||||  }||7 }d}|jt j@ rW|j	| }|d }d}|jt j@ rd|j	| }t|||| j|t
rp| jndt
rw| jS i S )z9Fully vendored version of getfullargspec from Python 3.3.z{!r} is not a Python functionz{!r} is not a code objectr   N   )inspectismethod__func__
isfunction	TypeErrorformat__code__iscodeco_argcountco_varnamespy3kco_kwonlyargcountlistco_flags
CO_VARARGSCO_VARKEYWORDSr
   __defaults____kwdefaults____annotations__)	funcconargsnamesnkwargsr   r   r   r   r   r   r   inspect_getfullargspecA   s>   




r1   )reduce)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   b      
rA   c                 C   s   t | dS Nascii)base64	b64decoder>   xr   r   r   rF         rF   c                 C   s   t | dS rC   )rE   	b64encodedecoderG   r   r   r   rJ      rI   rJ   c                 C   s   | j |ddS )Nbackslashreplaceerrors)rK   textencodingr   r   r   decode_backslashreplace      rR   c                 C   s   | |k| |k  S r   r   )arA   r   r   r   cmp   rI   rU   Fc                 C   s@   |dur	|  |} |dur|| _n|dur|| _z| ~ ~~~w )a{  implement "raise" with cause support.

        :param exception: exception to raise
        :param with_traceback: will call exception.with_traceback()
        :param replace_context: an as-yet-unsupported feature.  This is
         an exception object which we are "replacing", e.g., it's our
         "cause" but we don't want it printed.    Basically just what
         ``__suppress_context__`` does but we don't want to suppress
         the enclosing context, if any.  So for now we make it the
         cause.
        :param from\_: the cause.  this actually sets the cause and doesn't
         hope to hide it someday.

        NF)with_traceback	__cause__)	exceptionrV   Zreplace_contextfrom_r   r   r   raise_   s   

rZ   c                 C   r   r   r   r?   r   r   r   u      r[   c                 C   r   r   r   r?   r   r   r   ue   r\   r]   c                 C   
   t | dS )N__call__)hasattr)fnr   r   r   callable   rB   rb   )izip_longest)r9   )r6   )r:   )r7   )r8   c                 C   r   r   r   r?   r   r   r   rA      r\   c                 C   s    |d u r
t d d S 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   re   c                 C   s   dd | D S )Nc                 s   s    | ]}t |V  qd S r   )ord).0byter   r   r   	<genexpr>   s    ziterbytes.<locals>.<genexpr>r   )bufr   r   r   	iterbytes   rS   rk   c                  G   s4   t | dkr| dd dd | d D f } t|  S )N   r   r   c                 S   s   g | ]}t |qS r   )str)rg   r   r   r   r   
<listcomp>   s    zimport_.<locals>.<listcomp>)lenr<   )r   r   r   r   import_   s    rp   c                  O   sH   | dtj}|d u rd S t| D ]}t|tst|}|| qd S )Nfile)popsysstdout	enumerate
isinstance
basestringrm   write)r   kwargsfpr   r   r   r   print_   s   
r{   c                 C   r^   )Nzutf-8unicoder?   r   r   r   r[   	  s   
c                 C   r^   )Nunicode_escaper|   r?   r   r   r   r]     rB   c                 C   s4   z|  |W S  ty   t| dd    Y S w )Nr   )rK   UnicodeDecodeErrorreprrO   r   r   r   rR     s
   c                 C   s8   t | tst| jdddS t | tr| jdddS | S )NrD   rL   rM   )rv   string_typesr}   r>   rP   r   r   r   safe_bytestring  s
   

r   zdef raise_(exception, with_traceback=None, replace_context=None, from_=False):
    if with_traceback:
        raise type(exception), exception, with_traceback
    else:
        raise exception
c                 C   sV   t | dddkrt| ddS t| tr'| jd|fv r| jS | jd | j S t| S )zvendored from python 3.7
__module__Ntypingztyping. builtins.)getattrr   replacerv   typer   __qualname__)
annotationbase_moduler   r   r   _formatannotation1  s   
r   r   c                 C      d|  S )N*r   namer   r   r   r   E      c                 C   r   )Nz**r   r   r   r   r   r   F  r   c                 C   s   dt |  S )N=)r   )valuer   r   r   r   G  s    c                 C   r   )Nz -> r   r   r   r   r   r   H  r   c                    s   fdd}g }|rt | t | }t| D ]\}}||}|r0||kr0||
|||   }|| q|durD|||| n|rK|d |ri|D ]}||}|rc||v rc||
|| 7 }|| qO|durv||	|| dd| d }d v 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(   | }|  v r|d |   7 }|S )Nz: r   )r   resultr   formatannotation	formatargr   r   formatargandannotationY  s   z5inspect_formatargspec.<locals>.formatargandannotationNr   (z, )return)ro   ru   appendjoin)r   r   r   r   r   r   r   r   formatvarargsformatvarkwformatvalueformatreturnsr   r   specsfirstdefaultir   spec	kwonlyargr   r   r   r   inspect_formatargspec<  s2   
r   )formatargspecc                  O   s   t | dd i |S )Nr   rl   )_inspect_formatargspec)r   kwr   r   r   r     s   c                  g   s
   g }g }d}zRz| D ]}|j }|j}||  || q|V  W n   t }Y W |rF| }z|| r:d}W n   t }Y |s/|dkrXt|d |d |d  dS dS |rs| }z|| rgd}W n   t }Y |s\|dkrt|d |d |d  w w )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.

    )NNNr   r   r   N)__exit__	__enter__r   rs   exc_inforr   reraise)ZmanagersZexitsZvars_excZmgrZexit_Zenterr   r   r   nested  sL   



r   c                 C   sB   |du rt  }|\}}}|| ur|nd}tt| | ||d dS )legacy.  use raise\_()N)tbcause)rs   r   r   r   )rX   r   exc_type	exc_valueexc_tbr   r   r   r   raise_from_cause  s
   
r   c                 C   s   t |||d dS )r   )rV   rY   N)rZ   )tpr   r   r   r   r   r   r     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 u rt | |d|S | |S )Nr   )r   __new__)clsr   
this_basesdbasesmetar   r   r     s   z)with_metaclass.<locals>.metaclass.__new__N)__name__r   r   r   r_   __init__r   r   r   r   r   	metaclass  s    r   temporary_classNr   )r   r   r   r   r   r   with_metaclass  s   		r   )timezone)datetime	timedelta)tzinfoc                   @   s   e Zd ZdZdZdd Zdd Zdd Zd	d
 Zdd Z	dd Z
dd Zdd Zdd Zedd Zedd Zedd ZedddZe ZdS )r   z(Minimal port of python 3 timezone object_offsetc                 C   sD   t |ts	td| j|  kr| jkstd td|| _d S )Nzoffset must be a timedeltazYoffset must be a timedelta strictly between -timedelta(hours=24) and timedelta(hours=24).)rv   r   r   
_minoffset
_maxoffset
ValueErrorr   )selfoffsetr   r   r   r     s   

ztimezone.__init__c                 C   s   t |tkrdS | j|jkS )NF)r   r   r   )r   otherr   r   r   __eq__  s   ztimezone.__eq__c                 C   s
   t | jS r   )hashr   r   r   r   r   __hash__  rB   ztimezone.__hash__c                 C   s   d| j j| jf S )Nzsqlalchemy.util.%s(%r))	__class__r   r   r   r   r   r   __repr__  s   ztimezone.__repr__c                 C   s
   |  d S r   )tznamer   r   r   r   __str__  rB   ztimezone.__str__c                 C   s   | j S r   )r   r   dtr   r   r   	utcoffset  s   ztimezone.utcoffsetc                 C   s   |  | jS r   )_name_from_offsetr   r   r   r   r   r     s   ztimezone.tznamec                 C   s   d S r   r   r   r   r   r   dst  r\   ztimezone.dstc                 C   s.   t |tr|j| urtd|| j S td)Nzfromutc: dt.tzinfo is not selfz6fromutc() argument must be a datetime instance or None)rv   r   r   r   r   r   r   r   r   r   fromutc  s   


ztimezone.fromutcc                 C   s   | j d | j d | j S )z(backport of timedelta._to_microseconds()iQ i@B )dayssecondsmicrosecondsr   r   r   r   _timedelta_to_microseconds  s
   z#timezone._timedelta_to_microsecondsc                 C   s*   t t| t|\}}|tdd|fS )z backport of timedelta.__divmod__r   )divmodr   r   r   )rT   rA   qrr   r   r   _divmod_timedeltas  s
   ztimezone._divmod_timedeltasc                 C   s   | sdS | t dk rd}|  } nd}t| t dd\}}t|t dd\}}d|||f }|jr:|d	|jf 7 }|jrE|d
|jf 7 }|S )NUTCr   -+r   )hours)minuteszUTC%s%02d:%02dz:%02dz.%06d)r   r   r   r   r   )deltasignr   restr   r   r   r   r   r   %  s$   

ztimezone._name_from_offset   ;   )r   r   N)r   r   r   __doc__	__slots__r   r   r   r   r   r   r   r   r   staticmethodr   r   r   r   r   r   r   r   r   r   r     s(    	

	

r   )NNFr   )NN)qr   collections
contextlibr   operatorplatformrs   version_infoZpy36Zpy33Zpy35Zpy32r#   Zpy2kZpy265
startswithjythonr`   pypywin32Zosxcpythonmachinelowerarmcontextmanager
attrgetterZdottedgetter
namedtuplenextr
   	threadingImportErrorZdummy_threadingZ
safe_kwargrm   r1   rE   r   configparser	itertoolspickle	functoolsr2   ior3   Zbyte_bufferr4   r5   urllib.parser6   r7   r8   r9   r:   r   bytesZbinary_typesbinary_type	text_typeintZ	int_typesiterrk   filterfalseZitertools_filterfalsefilterZitertools_filtermapZitertools_imapr   re   rp   r{   rA   rF   rJ   rR   rU   rZ   r[   r]   rb   ConfigParser	cStringIOrc   urlliburlparsecPicklerw   r}   longifilterfalseifilterimapr   r;   r   r   r   r   collections.abcabccollections_abcr   r   r   r   r   r   r   r   utcr   r   r   r   <module>   s&  








&



%

			

B


"

]