
    +h                        d Z ddlZddlm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	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	 Z G d
 de      Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd]dZ G d de      Zd Z d]dZ!d Z"d^dZ#d_dZ$d_dZ%	 	 	 d`dZ&d  Z'd! Z(dad"Z) G d# d$e      Z*d% Z+d& Z,	 	 	 	 dbd'Z-d( Z.dcd)Z/ G d* d+e      Z0d, Z1 G d- d.e      Z2 G d/ d0e      Z3d1 Z4d2 Z5d3 Z6ddd4Z7d5 Z8d6 Z9d7 Z:d]d8Z;d9 Z<d: Z= G d; d<e>      Z? G d= d>e      Z@ G d? d@e      ZA G dA dBeB      ZCdCeC_D         G dD dCe      ZEdaFdE ZGdF ZHdedGZI G dH dIej                        ZKd]dJZLdK ZMdfdLZNdM ZO ej                  dN      ZQ ej                  dO      ZReReQfdPZS eTd      ZUdQ ZV G dR dSeT      ZWdT ZXdU ZYdV ZZdW Z[dX Z\ ej                  dY      Z]dZ Z^d[ Z_d\ Z`y)gzRoutines to help with the creation, loading and introspection of
modules, classes, hierarchies, attributes, functions, and methods.

    Nupdate_wrapper   )_collections)compat   )excc                     t         j                  r| j                  d      } t        j                         }|j                  |        |j                         S )Nzutf-8)r   py3kencodehashlibmd5update	hexdigest)xms     N/var/www/html/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.pymd5_hexr      s9    {{HHWAHHQK;;=    c                   (    e Zd ZdZdZddZd Zd Zy)safe_reraiseaK  Reraise an exception after invoking some
    handler code.

    Stores the existing exception info before
    invoking so that it is maintained across a potential
    coroutine context switch.

    e.g.::

        try:
            sess.commit()
        except:
            with safe_reraise():
                sess.rollback()

    )	warn_only	_exc_infoc                     || _         y N)r   )selfr   s     r   __init__zsafe_reraise.__init__:   s	    "r   c                 6    t        j                         | _        y r   )sysexc_infor   r   s    r   	__enter__zsafe_reraise.__enter__=   s    r   c                 j   |<| j                   \  }}}d | _         | j                  st        j                  ||       y y t        j                  sG| j                   r;| j                   d   r,t        d| j                   d   d| j                   d   d       d | _         t        j                  ||       y )N)with_tracebackr   z`An exception has occurred during handling of a previous exception.  The previous exception is:
 r    
)r   r   r   raise_r   warn)r   type_value	tracebackexc_type	exc_valueexc_tbs          r   __exit__zsafe_reraise.__exit__@   s    =*...'Hi!DN>>#) " ;;4>>dnnQ6G  (,~~a'8$..:KM
 "DNMM%	:r   NF)__name__
__module____qualname____doc__	__slots__r   r"   r/    r   r   r   r   &   s    " +I#(;r   r   c              #      K   t               }| g}|rM|j                         } | |v r|j                  |        |j                  | j	                                |  |rLy y wr   )setpopaddextend__subclasses__)clsseenstacks      r   walk_subclassesr@   W   sV     5DEE
iik$;HHSMS'')*	 s   AA A c                 z    t        | t        j                        r| S 	 t        |       S # t        $ r d| z  cY S w xY w)Nzunprintable element %r)
isinstancer   string_typesstr	Exception)elements    r   string_or_unprintablerG   e   s@    '6../	6w< 	6+g55	6s   
) ::c                 n    dj                  d t        j                  d| j                        D              S )Nr%   c              3   <   K   | ]  }|j                           y wr   )lower).0ns     r   	<genexpr>z(clsname_as_plain_name.<locals>.<genexpr>p   s      	s   z([A-Z][a-z]+))joinrefindallr1   )r=   s    r   clsname_as_plain_namerQ   o   s0    88 ::&6E  r   c                 z    t        | t              s| j                  }n| }|j                  }t	        ||      }||k7  S )z1Return True if the two class methods don't match.)rB   type	__class__r1   getattr)instance_or_clsagainst_methodcurrent_clsmethod_namecurrent_methods        r   method_is_overriddenr[   u   s@     ot,%//% ))K[+6N^++r   c                     g }| j                   | j                  | j                  fD ]/  }t        |d      r|j	                         }|j                  |       1 t        |      S )zrdecode a slice object as sent to __getitem__.

    takes into account the 2.5 __index__() method, basically.

    	__index__)startstopstephasattrr]   appendtuple)slcretr   s      r   decode_slicerf      sW     CYY#((* 1k"A

1 :r   c           
   '      K   t        |       } |D ]h  t        j                  ft        j                  fdt        d                  }|D ]  }|| vs| j                  |       |  [ t        dz         y w)Nc                      t        |       z   S r   )rD   )ibases    r   <lambda>z!_unique_symbols.<locals>.<lambda>   s    D3q6M r   i  z&exhausted namespace for symbol base %s)r8   	itertoolschainr   itertools_imapranger:   	NameError)usedbasespoolsymrj   s       @r   _unique_symbolsru      s     t9D MG!!"95;G
  	MC$			M DtKLLMs   AA=(A=c              #   H   K   |r|| dz   z  } | |       ||z  }|ryyw)z6Call the given function given each nonzero bit from n.r   Nr6   )fnrL   bs      r   map_bitsry      s1      !aLe	Q s   ""c                 &      fd}t        |       S )z'A signature-matching decorator factory.c                 `   t        j                  |       s t        j                  |       st        d      t	        j
                  |       }i }t        ||      }t        |d         |dd z   | j                  fz   }t        |dd      \  }}t        ||      }|j                  t        |d	             | j                  |d
<   d|z  }|j                  |	|| d| j                  i       t        ||| j                        }t        | d|       j                   |_        | |_        t%        ||       S )Nznot a decoratable functionr   r      targetrw   )r}   rw   FgroupednamezDdef %(name)s(%(args)s):
    return %(target)s(%(fn)s, %(apply_kw)s)
r1   __func__)inspect
isfunctionismethodrE   r   inspect_getfullargspec!_update_argspec_defaults_into_envrc   r1   ru   dictr   format_argspec_plusr2   _exec_code_in_envrU   __defaults____wrapped__r   )
rw   specenvnames	targ_namefn_namemetadatacode	decoratedr}   s
            r   decoratezdecorator.<locals>.decorate   s    !!"%g.>.>r.B899,,R00s;d1ga*bkk^;,UHdC	7yW5+D%@A;; 	 	 	

IvwJNO%dC=	!(Z!<!I!I	 "	i,,r   r   )r}   r   s   ` r   	decoratorr      s    -: (F++r   c                 0   | j                   rg }d}| j                   D ]K  }t        |      j                  dvr!d|z  }|||<   |j                  |       |dz  };|j                  |       M t	        |       }t        |      |d<   t        j                  | S | S )zCgiven a FullArgSpec, convert defaults to be symbol names in an env.r   )builtins__builtin__zx%dr   r|   )defaultsrS   r2   rb   listrc   r   FullArgSpec)r   r   new_defaultsri   argr   elems          r   r   r      s     }}== 	)CCy##+FFqyD	##D)Q##C(	) Dz%Q!!4((r   c                 $    t        | |       ||   S r   )exec)r   r   r   s      r   r   r      s    sOw<r   c           
         t        | t              r)| j                  }| }d|r|nd| j                  z  d|d}n	| x}}d|z  }|j	                  d      d   }t        j                  |      }|d   d= t        |d	
      }||d<   d|z  }	|t        |j                  d}
t        |	|
       |
|   }t        |d      rW|j                  \  }}|j                  }|| j                  d| j                  }t        |d|d|d|dd      }||_        n|j                  |_        d|j                  dd      d   z   |_	        |j                  t         j"                  vrt%        d|j                  d      t
        j&                  st        |d      r<||j(                  _        t        |j(                  d      s||f|j(                  _        |S ||_        t        |d      s	||f|_        |S )zProduce a wrapping function for the given cls or classmethod.

    Rationale here is so that the __init__ method of the
    class can serve as documentation for the function.

    zConstruct a new :class:`z.%szX` object. 

This constructor is mirrored as a public API function; see :func:`sqlalchemyz,` for a full usage and argument description.zSThis function is mirrored; see :func:`sqlalchemy%s` for a description of arguments..r   Fr~   r   z5def %(name)s(%(args)s):
    return cls(%(apply_kw)s)
)r=   symbolr1   
_linked_toz[.. container:: inherited_member

    This documentation is inherited from :func:`sqlalchemyz&`; this constructor, :func:`sqlalchemyz!`,   creates a :class:`sqlalchemyzJ` object.  See that class for additional details describing this subclass.r   
sqlalchemyzpublic_factory location z is not in sys.modulesr   )rB   rS   r   r1   splitr   r   r   r   r2   r   ra   r   r4   inject_docstring_textrsplitr   modulesImportErrorpy2kr   )r}   locationclass_locationrw   	callable_doclocation_namer   r   r   r   r   	linked_tolinked_to_locationlinked_to_docs                  r   public_factoryr      s    &$__	 #1efoo6MM 	  Y.089 	
 NN3'+M((,DQ
"47H$HV	 		 	 ((C
 	sOM"Ir< (*%	%!))!(.(9(96??KN- "8^= 	
 *	JJ	'(//#q*A!*DDI3;;.##&
 	

 {{gb*-!r{{L1&/%:BKK" 	 
r<(&1BMr   c                   &    e Zd ZddZd Zd Zd Zy)PluginLoaderNc                 .    || _         i | _        || _        y r   )groupimplsauto_fn)r   r   r   s      r   r   zPluginLoader.__init__@  s    

r   c                 8    | j                   j                          y r   )r   clearr!   s    r   r   zPluginLoader.clearE  s    

r   c                    || j                   v r | j                   |          S | j                  r)| j                  |      }|r|| j                   |<    |       S t        j                  | j                        D ]<  }|j
                  |k(  s|j                  | j                   |<   |j                         c S  t        j                  d| j                  d|      )NzCan't load plugin: :)	r   r   r   importlib_metadata_getr   r   loadr	   NoSuchModuleError)r   r   loaderimpls       r   r   zPluginLoader.loadH  s    4::#4::d#%%<<\\$'F#)

4 x11$**= 	#DyyD #'99

4 yy{"	#
 ##*.**d;
 	
r   c                 2    fd}|| j                   |<   y )Nc                      t        j                        } j                  d      dd  D ]  }t        | |      }  t        |       S )Nr   r   )r   import_r   rU   )modtoken
modulepathobjnames     r   r   z#PluginLoader.register.<locals>.load\  sK    ..,C#))#.qr2 *c5)*3((r   )r   )r   r   r   r   r   s     `` r   registerzPluginLoader.register[  s    	)  

4r   r   )r1   r2   r3   r   r   r   r   r6   r   r   r   r   ?  s    

& r   r   c                 "   	 t         j                  }| j                  }|j                  }t	        |j
                  d |       t        |j                  |z        fS # t        $ r+ t        j                  |       }|d   t        |d         fcY S w xY w)Nr   r   )r   CO_VARKEYWORDS__code__co_argcountr   co_varnamesboolco_flagsAttributeErrorr   r   )rw   co_varkeywordsconargsr   s        r   _inspect_func_argsr   e  s    
 // [['(~-.
 	
  &
 ,,R0AwT!W%%&s   A 1BBc                    |du }|r
t               }| j                  j                  dd      }|xr@ t        |t        j
                        xr$ t        |j                  t        j                        }|r$t        |      \  }}|j                  |       |s|sy|rr| j                  D ]  }t        ||       n |j                  d       |S )ae  Return the full set of inherited kwargs for the given `cls`.

    Probes a class's __init__ method, collecting all named arguments.  If the
    __init__ defines a \**kwargs catch-all, then the constructor is presumed
    to pass along unrecognized keywords to its base classes, and the
    collection process is repeated recursively on each of the bases.

    Uses a subset of inspect.getfullargspec() to cut down on method overhead,
    as this is used within the Core typing system to create copies of type
    objects which is a performance-sensitive operation.

    No anonymous tuple arguments please !

    Nr   Fr   )r8   __dict__getrB   typesFunctionTyper   CodeTyper   r   	__bases__get_cls_kwargsdiscard)r=   _settoplevelctrhas_initr   has_kwcs           r   r   r   y  s     t|Hu
,,

:u
-C 	 	5sE../	5s||U^^4  *3/vEhv 	Aa&.	 	LLKr   c                 2    t        j                  |       d   S )zReturn the set of legal kwargs for the given `func`.

    Uses getargspec so is safe to call for methods, functions,
    etc.

    r   )r   r   )funcs    r   get_func_kwargsr     s     ((.q11r   c           	         t        j                  |       rt        d| z        t        j                  |       r|r{|ryt	        j
                  |       }t	        j                  |j                  dd |j                  |j                  |j                  |j                  |j                  |j                        S t	        j
                  |       S t        j                  |       r|r|s| j                  rt	        j
                  | j                         }t	        j                  |j                  dd |j                  |j                  |j                  |j                  |j                  |j                        S t	        j
                  | j                         S t        j"                  |       rt%        | j&                  |d      S t)        | d      rt	        j
                  | j                         S t)        | d      rDt        j                  | j*                        rt%        | j*                  |      S t        d	| z        t        d	| z        )
zReturn the argument signature for any callable.

    All pure-Python callables are accepted, including
    functions, methods, classes, objects with __call__;
    builtins and other edge cases like functools.partial() objects
    raise a TypeError.

    zCan't inspect builtin: %sr   NT)no_self_is_initr   __call__)r   zCan't inspect callable: %s)r   	isbuiltin	TypeErrorr   r   r   r   argsvarargsvarkwr   
kwonlyargskwonlydefaultsannotationsr   __self__r   isclassget_callable_argspecr   ra   r   )rw   r   r   r   s       r   r   r     s    3b899			B	004D%%		!"

##    0044			"	BKK00=D%%		!"

##    00==		#KK4
 	
 
Z	 ,,R[[99	Z	 BKK('WEE82=>>4r9::r   c           
         t        j                  |       rt        j                  |       }n| }t        j                  | }t        j                  |d   |d   |d   d|d         }|d   r1|d   d   }t        j                  |d   dd |d   |d   d|d         }n|d   rd|d   z  }|}nd}|}d}|d   r|t	        |d         z  }|d   r|t	        |d         z  }|d   |d   z   }|r	|d|z
  d }	nd}	t        j                  ||d   |d   |	d	 
      }
|d   r%t        j                  |dd |d   |d   |	d 
      }n|
}|rt        ||||
||      S t        |dd ||dd |
dd |dd |dd       S )a   Returns a dictionary of formatted, introspected function arguments.

    A enhanced variant of inspect.formatargspec to support code generation.

    fn
       An inspectable callable or tuple of inspect getargspec() results.
    grouped
      Defaults to True; include (parens, around, argument) lists

    Returns:

    args
      Full inspect.formatargspec for fn
    self_arg
      The name of the first positional argument, varargs[0], or None
      if the function defines no positional arguments.
    apply_pos
      args, re-written in calling rather than receiving syntax.  Arguments are
      passed positionally.
    apply_kw
      Like apply_pos, except keyword-ish args are passed as keywords.
    apply_pos_proxied
      Like apply_pos but omits the self/cls argument

    Example::

      >>> format_argspec_plus(lambda self, a, b, c=3, **d: 123)
      {'args': '(self, a, b, c=3, **d)',
       'self_arg': 'self',
       'apply_kw': '(self, a, b, c=c, **d)',
       'apply_pos': '(self, a, b, c, **d)'}

    r   r   r   N   z%s[0]r|   r6   c                     d| z   S N=r6   r   s    r   rk   z%format_argspec_plus.<locals>.<lambda>3  s
    cAg r   )formatvaluec                     d| z   S r   r6   r   s    r   rk   z%format_argspec_plus.<locals>.<lambda><  s
    #' r   )r   self_arg	apply_posapply_kwapply_pos_proxiedapply_kw_proxiedr   )r   callabler   inspect_formatargspeclenr   )rw   r   r   r   r  r  r  num_defaults	name_argsdefaulted_valsr  r  s               r   r   r     s   D r,,R0''.D,,Qa$q'4aI Aw71:"88GABKa$q'4a
 
aT!W$%%LAwDG$AwDG$Q$q'!I"1|#3#56++QQ%H Aw!77abMGG)
 $/-
 	
 a"oa^/"5-a3
 	
r   c                     | t         j                  u r|rdnd}|rdnd}n	 t        | |      S t	        d|||||
      S # t        $ r |rdnd}|rdnd	}Y (w xY w)a  format_argspec_plus with considerations for typical __init__ methods

    Wraps format_argspec_plus with error handling strategies for typical
    __init__ cases::

      object.__init__ -> (self)
      other unreflectable (usually C) -> (self, *args, **kwargs)

    z(self)r   z() r~   z(self, *args, **kwargs)zself, *args, **kwargsz(*args, **kwargs)z*args, **kwargs)r  r   r  r  r  r  )objectr   r   r   r   )methodr   r   proxieds       r   format_argspec_initr  U  s      "x!$r	L&vw?? !    	L  *, 
 .5):KG	Ls   ? AAc                 &      fd}|S )zA class decorator that will copy attributes to a proxy class.

    The class to be instrumented must define a single accessor "_proxied".

    c           	      t   d	
fd	}	
fd}D ]2  }t        | |      rt        d| d|      t        | | ||             4 D ]2  }t        | |      rt        d| d|      t        | | ||             4 D ]4  }t        | |      rt        d| d|      t        | | ||d             6 | S )Nc                    t        
|       }t        j                  |      }d|j                  i}t	        ||      }t        |d      }|j                  |d   |d   |d   |d   d}|rd	|z  }
|d
<   nd|z  }t        |||j                        }t        |d|      j                  |_        t        |j                  dd	dd      |_
        |rt        |      }|S )Nr1   Fr~   r  r  r   r  )r   r  r  r   r  zLdef %(name)s(%(args)s):
    return target_cls.%(name)s(%(apply_kw_proxied)s)
target_clszWdef %(name)s(%(args)s):
    return %(self_arg)s._proxied.%(name)s(%(apply_kw_proxied)s)r   0.. container:: class_bases

    Proxied for the  class on behalf of the  class.r   )rU   r   r   r2   r   r   r1   r   r   r   r4   classmethod)r   clslevelrw   r   r   caller_argspecr   r   proxy_fnproxy_cls_sphinx_namer  target_cls_sphinx_names            r   
instrumentz:create_proxy_methods.<locals>.decorate.<locals>.instrument  s   T*B004Dr}}-C4T3?D0uEN %34G%H$23E$F&v.*:6H K 
 %/L!V  )sBKK@H$+B
B$?$L$LH!4

 *+@B  H &x0Or   c                     j                   j                  | d       }|t        |j                  dddd      }nd }dd| iz  }t	        |d|id      }|S )	Nr  r  r  r   zdef set_(self, attr):
    self._proxied.%(name)s = attr
def get(self):
    return self._proxied.%(name)s
get.__doc__ = doc
getset = property(get, set_)r   r   getset)r   r   r   r4   r   )r   attrr   r   r"  r  r  r  s        r   makepropz8create_proxy_methods.<locals>.decorate.<locals>.makeprop  sy    &&**46D+LL /-	 	 / D 'teS\8DFMr   zclass z already has a method Tr  r0   )ra   r   setattr)r=   r   r$  methprop
attributesclassmethodsmethodsr  r  r  s        r   r   z&create_proxy_methods.<locals>.decorate  s    +	Z	<  	1DsD!:=tD  Cz$/0	1  	/DsD!:=tD  Cx~.	/ ! 	@DsD!:=tD  Cz$>?	@ 
r   r6   )r  r  r  r*  r+  r)  r   s   `````` r   create_proxy_methodsr,  v  s    a aF Or   c                     	 t        j                  |       S # t        $ r% | t        j                  u r	dgdddfcY S dgdddfcY S w xY w)zinspect.getargspec with considerations for typical __init__ methods

    Wraps inspect.getargspec with error handling for typical __init__ cases::

      object.__init__ -> (self)
      other unreflectable (usually C) -> (self, *args, **kwargs)

    r   Nr   kwargs)r   r   r   r  r   )r  s    r   getargspec_initr/    sU    6,,V44 6V__$HdD$//Hfh55	6s    "AAAc                 j    t        | t        j                        r| j                  s| j                  S | S )zSAdjust the incoming callable such that a 'self' argument is not
    required.

    )rB   r   
MethodTyper   r   )func_or_clss    r   unbound_method_to_callabler3    s.     +u//09M9M###r   c           	      v    | g}nt        j                  |      }t               }g }t        j                         }d}t	        |      D ]%  \  }}		 t        j                  |	j                        }
|
j                  xr t        |
j                        xs d}|dk(  rY|
j                  r|
j                  }|r |j                  |
j                  d|         nN|j                  |
j                  dd        n/|j                  |
j                  d|  D cg c]  }||f c}       |s|j                  t        |
j                  | d |
j                        D cg c]	  \  }}||f c}}       ( g }|j                   fd|D               |>t!         |      r2|j                  t#         |      D cg c]  }t%        |       c}       |j'                         D ]7  \  }}||v r	 t#         ||      }||ur||k7  r|j)                  |d|       9 |r7|D ]2  \  }}	 t#         ||      }||ur||k7  r|j)                  |d|       4  j,                  j.                  ddj1                  |      dS c c}w c c}}w # t        $ r Y Jw xY wc c}w # t*        $ r Y w xY w# t*        $ r Y w xY w)	z}Produce a __repr__() based on direct association of the __init__()
    specification vs. same-named attributes present.

    Nr   r   c              3   J   K   | ]  }t        t        |d               y wr   )reprrU   )rK   r   objs     r   rM   zgeneric_repr.<locals>.<genexpr>5  s     DC$wsC./Ds    #r   (, ))r   to_listr  OrderedDict	enumerater   r   r   r   r	  r   r;   r   r   zipr   ra   rU   r6  itemsrb   rE   rT   r1   rN   )r7  additional_kw
to_inspect
omit_kwargmissingpos_argskw_argsvargsri   inspr   default_lenr   defaultoutputvaldefvals   `                r   generic_reprrM    s   
 U
!))*5
hGH&&(GEZ( 4	00?D -->C,>C!KAv<< LLEOODIIa$=>OODIIabM2/3yyK</HIc7^I  -0 II{lm4dmm-(C g)8 F
MMD8DDWS%0GC,?@StCy@A}} V*	#sG,C'!cVmc23 ( 	KCc30g%#-MMS#"67		 }}--tyy/@AAM J
%  		< A  		  sH   JI=
J6J+,J$,J,	JJ	J)(J),	J87J8c                   .    e Zd ZdZdZd Zd ZddZd Zy)	portable_instancemethodz_Turn an instancemethod into a (parent, name) pair
    to produce a serializable callable.

    )r}   r   r.  __weakref__c                 J    | j                   | j                  | j                  dS )Nr}   r   r.  rR  r!   s    r   __getstate__z$portable_instancemethod.__getstate__X  s!    kkIIkk
 	
r   c                 Z    |d   | _         |d   | _        |j                  dd      | _        y )Nr}   r   r.  r6   )r}   r   r   r.  )r   states     r   __setstate__z$portable_instancemethod.__setstate___  s*    Ho&M	ii"-r   c                 V    |j                   | _        |j                  | _        || _        y r   )r   r}   r1   r   r.  )r   r'  r.  s      r   r   z portable_instancemethod.__init__d  s    mmMM	r   c                     |j                  | j                          t        | j                  | j                        |i |S r   )r   r.  rU   r}   r   )r   r   kws      r   r   z portable_instancemethod.__call__i  s3    
		$++.wt{{DII.:r::r   N)r6   )	r1   r2   r3   r4   r5   rS  rV  r   r   r6   r   r   rO  rO  P  s"    
 :I
.

;r   rO  c                    t         j                  r$t        | t        j                        r
t               S | ht        | j                        }|r%|j                         }t         j                  r1t        |t        j                        r>fd|j                  D        }nfd|j                  D        }|D ]$  }|j                  |       j                  |       & t         j                  r|j                  dk(  st        |d      s|j                  dk(  st        |d      s|j                         D cg c]	  }|vs| c}D ]$  }|j                  |       j                  |       & |r%t              S c c}w )a  Return an unordered sequence of all classes related to cls.

    Traverses diamond hierarchies.

    Fibs slightly: subclasses of builtin types are not returned.  Thus
    class_hierarchy(class A(object)) returns (A, object), not A plus every
    class systemwide that derives from object.

    Old-style classes are discarded and hierarchies rooted on them
    will not be descended.

    c              3   ^   K   | ]$  }|vrt        |t        j                        s| & y wr   )rB   r   	ClassTyperK   _hiers     r   rM   z"class_hierarchy.<locals>.<genexpr>  s-      D=Au)G s   *-c              3   ,   K   | ]  }|vs|  y wr   r6   r]  s     r   rM   z"class_hierarchy.<locals>.<genexpr>  s     =1q}Q=s   	r   r<   r   )r   r   rB   r   r\  r   __mro__r9   r   rb   r:   r   r2   ra   r<   )r=   processr   rr   rx   r^  sr_  s          @r   class_hierarchyrd  n  s<    {{c5??+6M5D3;;G
KKM;;!U__-E >=E 	ANN1HHQK	 ;;||z)<L1M||},G#5 --/A1D=!A 	ANN1HHQK	5 : : Bs   :	FFc              #      K   t        |       }|D ]6  }| j                  D ]%  }||j                  v s||j                  |   f  6 8 yw)ziterate all the keys and attributes associated
    with a class, without using getattr().

    Does not use getattr() so that class-sensitive
    descriptors (i.e. property.__get__()) are not called.

    N)dirra  r   )r=   keyskeyr   s       r   iterate_attributesri    sU      s8D  	Aajj AJJsO,,	s
   .A
A
c                    |r|}nN|d}t        |      D cg c]6  }|j                  d      r#|j                  d      rt        | |      s||vr|8 }}|D ]  }	 t	        ||      }	t        |	d      st	        |	d|	      }		 t        j                  |	      }
t        j                  |
d         }t        j                  |
d   dd       }d
t               z  }|duxr ||ixs i }t        j                  ||       	 |	j                  ||   _        t        | |||           yc c}w # t
        $ r Y w xY w# t        $ r d}d	}Y |w xY w# t
        $ r Y Ew xY w)z9Automates delegation of __specials__ for a proxying type.N)r5   __del____getattribute____metaclass__rS  rV  __r   r   r   r   z(self, *args, **kw)z(*args, **kw)z?def %(method)s%(fn_args)s: return %(name)s.%(method)s%(d_args)s)rf  
startswithendswithra   rU   r   r   r   r  r   localsexec_r   r&  )into_clsfrom_clsskiponlyr   from_instancedundersr   r  rw   r   fn_argsd_argspyr   s                  r   monkeypatch_proxied_specialsr|    s    <D ]	
T"JJt$!,TM 	
 	
  /	6*B2z*Z,B	%004D2247;G11$q'!"+>F35;X> 	
 4'AT=,AGRR	')CK$ 	&#f+.7/	
"  		  	%+G$F	%  		sB   ;D"D'3D'AD6;E	'	D32D36EE		EEc                 6    t        | d|       t        |d|      u S )z;Return True if the two methods are the same implementation.r   )rU   )meth1meth2s     r   methods_equivalentr    s(     5*e,z51  r   c           	         |s|st        d      t        |t              rt        | |      r| S t        |xs+ t	        |      D cg c]  }|j                  d      r| c}      }t        t	        |             }t        j                  }t        |t              r|}n(|st               }t        j                  }nt        |      } ||j                  |      |      r| S t        | t              s<|t        j                  u xr dxs d}t        | d|ddj                  |             G d d	t              }	|rd
|j                  z   |	_        t               }
t        |       D ]d  \  }}||vrt        d|z        t        j                   |      st        |d|d      t#        |	|t%        |             |
j'                  |       f  ||
|      r|	S t        ddj                  ||
z
        z        c c}w )a  Ensure basic interface compliance for an instance or dict of callables.

    Checks that ``obj`` implements public methods of ``cls`` or has members
    listed in ``methods``. If ``required`` is not supplied, implementing at
    least one interface method is sufficient. Methods present on ``obj`` that
    are not in the interface are ignored.

    If ``obj`` is a dict and ``dict`` does not meet the interface
    requirements, the keys of the dictionary are inspected. Keys present in
    ``obj`` that are not in the interface will raise TypeErrors.

    Raises TypeError if ``obj`` does not meet the interface criteria.

    In all passing cases, an object with callable members is returned.  In the
    simple case, ``obj`` is returned as-is; if dict processing kicks in then
    an anonymous class is returned.

    obj
      A type, instance, or dictionary of callables.
    cls
      Optional, a type.  All public methods of cls are considered the
      interface.  An ``obj`` instance of cls will always pass, ignoring
      ``required``..
    methods
      Optional, a sequence of method names to consider as the interface.
    required
      Optional, a sequence of mandatory implementations. If omitted, an
      ``obj`` that provides at least one interface method is considered
      sufficient.  As a convenience, required may be a type, in which case
      all public methods of the type are required.

    z2a class or collection of method names are requiredr^  zany ofzall ofz does not implement z: r9  c                       e Zd ZdZy)(as_interface.<locals>.AnonymousInterfacezA callable-holding shell.N)r1   r2   r3   r4   r6   r   r   AnonymousInterfacer  6  s    'r   r  	Anonymousz%r: unknown in this interfacer   z is not callablez,dictionary does not contain required keys %s)r   rB   rS   r8   rf  ro  operatorgegtintersectionr   rN   r  r1   dictlike_iteritemsr   r  r&  staticmethodr:   )r7  r=   r+  requiredr   	interfaceimplementedcomplies	qualifierr  foundr  r   s                r   as_interfacer    s   B wLMM#tC!5
GM3s8Ma1<<;LMNIc#h-K{{H(D!5;;x=((3X>
 c4 +8DH	Ityy35
 	

(V ( &1CLL&@#EE*3/ ";fDEEt$vtDEE"FL,>?		& x !!
6
))Hu$
%	& S  Ns   G7G7c                   4    e Zd ZdZddZd Zd Zed        Zy)memoized_propertyz2A read-only @property that is only evaluated once.Nc                 ^    || _         |xs |j                  | _        |j                  | _        y r   fgetr4   r1   r   r  r   s      r   r   zmemoized_property.__init__Q  s$    	*dllr   c                 b    || S | j                  |      x|j                  | j                  <   }|S r   )r  r   r1   r   r7  r=   results       r   __get__zmemoized_property.__get__V  s0    ;K/3yy~=T]]#fr   c                 D    t         j                  || j                         y r   )r  resetr1   )r   r7  s     r   _resetzmemoized_property._reset\  s    T]]3r   c                 <    |j                   j                  |d        y r   )r   r9   )r=   r7  r   s      r   r  zmemoized_property.reset_  s    t$r   r   )	r1   r2   r3   r4   r   r  r  r  r  r6   r   r   r  r  N  s(    <&
4 % %r   r  c                 &      fd}t        |       S )zDecorate a method memoize its return value.

    Best applied to no-arg methods: memoization is not sensitive to
    argument values, and will always return the same value even when
    called with different arguments.

    c                      | g|i |fd}j                   |_         j                  |_        || j                  j                   <   S )Nc                      S r   r6   arY  r  s     r   memoz6memoized_instancemethod.<locals>.oneshot.<locals>.memop  s    Mr   )r1   r4   r   r   r   rY  r  r  rw   s       @r   oneshotz(memoized_instancemethod.<locals>.oneshotm  sK    D&4&2&	 zz%)bkk"r   r   )rw   r  s   ` r   memoized_instancemethodr  d  s    	 '2&&r   c                   Z    e Zd ZdZdZ e       Zd Zd Zd Z	 G d de
      Zed        Zy	)
HasMemoizedzyA class that maintains the names of memoized elements in a
    collection for easy cache clearing, generative, etc.

    r6   c                 ^    | j                   D ]  }| j                  j                  |d          y r   )_memoized_keysr   r9   r   r   s     r   _reset_memoizationszHasMemoized._reset_memoizations  s+    '' 	*DMMdD)	*r   c                 F    | j                   D ]  }|| j                  vrJ  y r   )r  r   r  s     r   _assert_no_memoizationsz#HasMemoized._assert_no_memoizations  s)    '' 	-Dt}},,,	-r   c                 N    || j                   |<   | xj                  |hz  c_        y r   )r   r  )r   rh  r*   s      r   _set_memoized_attributez#HasMemoized._set_memoized_attribute  s#    "cu$r   c                       e Zd ZdZddZd Zy)HasMemoized.memoized_attributezTA read-only @property that is only evaluated once.

        :meta private:

        Nc                 ^    || _         |xs |j                  | _        |j                  | _        y r   r  r  s      r   r   z'HasMemoized.memoized_attribute.__init__  s$    DI.$,,DL MMDMr   c                     || S | j                  |      x|j                  | j                  <   }|xj                  | j                  hz  c_        |S r   )r  r   r1   r  r  s       r   r  z&HasMemoized.memoized_attribute.__get__  sG    {3799S>ACLL'&4==/1Mr   r   )r1   r2   r3   r4   r   r  r6   r   r   memoized_attributer    s    		*
	r   r  c                 &    fd}t        |      S )z+Decorate a method memoize its return value.c                      | g|i |fd}j                   |_         j                  |_        || j                  j                   <   | xj                  j                   hz  c_        S )Nc                      S r   r6   r  s     r   r  zBHasMemoized.memoized_instancemethod.<locals>.oneshot.<locals>.memo  s    r   )r1   r4   r   r  r  s       @r   r  z4HasMemoized.memoized_instancemethod.<locals>.oneshot  sb    *t*r*F KKDM::DL)-DMM"++&BKK=0Mr   r   )r=   rw   r  s    ` r   r  z#HasMemoized.memoized_instancemethod  s    
	 gr**r   N)r1   r2   r3   r4   r5   	frozensetr  r  r  r  r  r  r  r  r6   r   r   r  r  {  sD    
 I[N*-%V & + +r   r  c                        e Zd ZdZdZd Zd Zy)MemoizedSlotszApply memoized items to an object using a __getattr__ scheme.

    This allows the functionality of memoized_property and
    memoized_instancemethod to be available to a class using __slots__.

    r6   c                     t        |      r   )r   )r   rh  s     r   _fallback_getattrzMemoizedSlots._fallback_getattr  s    S!!r   c                 6    j                  d      rt              t         dz        r# t         dz               }t	         |       |S t         dz        r)t         dz         fd}j
                  |_        |S  j                        S )N	_memoizedz_memoized_attr_%sz_memoized_method_%sc                       | i |fd}j                   |_         j                  |_        t        |       S )Nc                      S r   r6   r  s     r   r  z8MemoizedSlots.__getattr__.<locals>.oneshot.<locals>.memo  s    !Mr   )r1   r4   r&  )r   rY  r  r  rw   rh  r   s      @r   r  z*MemoizedSlots.__getattr__.<locals>.oneshot  s>    TR" !#!zzc4(r   )ro  r   ra   rU   r&  r4   r  )r   rh  r*   r  rw   s   ``  @r   __getattr__zMemoizedSlots.__getattr__  s    >>+& %%T.45<GD"5";<>ED#u%LT03674s:;B	 !jjGON))#..r   N)r1   r2   r3   r4   r5   r  r  r6   r   r   r  r    s     I"/r   r  c                     t        | t        j                        r6| j                         j	                         } | dv ry| dv ryt        d| z        t        |       S )N)trueyesonyt1T)falsenooffrL   f0FzString is not true/false: %r)rB   r   rC   striprJ   
ValueErrorr   )r7  s    r   asboolr    sY    #v**+iik!6699;cABB9r   c                        fd}|S )zqReturn a callable that will evaluate a string as
    boolean, or one of a set of "alternate" string values.

    c                 &    | v r| S t        |       S r   )r  )r7  texts    r   bool_or_valuez"bool_or_str.<locals>.bool_or_value  s    $;J#;r   r6   )r  r  s   ` r   bool_or_strr    s     r   c                      | | S t        |       S )zCoerce to integer.)int)r*   s    r   asintr    s     }u:r   c                     || }|| v rQt        |t              rt        | |   |      s1| |   +|t        u r|rt        | |         ||<   y || |         ||<   yyyy)zIf 'key' is present in dict 'kw', coerce its value to type 'type\_' if
    necessary.  If 'flexi_bool' is True, the string '0' is considered false
    when coercing to boolean.
    N)rB   rS   r   r  )rY  rh  r)   
flexi_booldests        r   coerce_kw_typer    ss     | 	r	E4(
2c7E0JsGD=Zr#wDIbgDI   1K 	r   c                 J     t        |      }|ft         fd|D              z   S )zbProduce a tuple structure that is cacheable using the __dict__ of
    obj to retrieve values

    c              3   ^   K   | ]$  }|j                   v s|j                   |   f & y wr   r   rK   kr7  s     r   rM   z"constructor_key.<locals>.<genexpr>  s.      !"qCLL/@CLLO   --)r   rc   )r7  r=   r   s   `  r   constructor_keyr    s2    
 3E6E &+   r   c                 |     t        |      }|j                   fd|j                  |      D                ||i |S )zInstantiate cls using the __dict__ of obj as constructor arguments.

    Uses inspect to match the named arguments of ``cls``.

    c              3   ^   K   | ]$  }|j                   v s|j                   |   f & y wr   r  r  s     r   rM   z#constructor_copy.<locals>.<genexpr>*  s.      !"a3<<>OCLLOr  )r   r   
difference)r7  r=   r   rY  r   s   `    r   constructor_copyr  "  sE     3EII &+&6&6r&:  r   c                  |    t         j                  j                         t        j                  d      fd} | S )z%Return a threadsafe counter function.r   c                  J    5  t               cd d d        S # 1 sw Y   y xY wr   )next)counterlocks   r   _nextzcounter.<locals>._next7  s"     	!=	! 	! 	!s   ")r   	threadingLockrl   count)r  r  r  s    @@r   r  r  0  s3       "Dooa G! Lr   c                    t        | d      r8| j                   t        | j                  t              rt        S | j                  S t	        | t
              xr t        xs t        } || t              rt        S  || t              rt        S  || t              rt        S t        | d      rt        S t        | d      rt        S t        | d      rt        S |S )zGiven an instance or class, guess if it is or is acting as one of
    the basic collection types: list, set and dict.  If the __emulates__
    property is present, return that preferentially.
    __emulates__rb   r:   r8   )ra   r  
issubclassr8   rB   rS   r   r   )specimenrI  isas      r   duck_type_collectionr  >  s     x(  ,!!32
 J(((
Xt
$
3
AzC
8T	Xs	
	Xt	x"	5	!
	5	!r   c           
      
   t        | |      r| S t        |t              r>t        j                  d|ddj	                  d |D              dt        |       d      t        j                  d|d|dt        |       d      )	Nz
Argument 'z ' is expected to be one of type z or c              3   &   K   | ]	  }d |z    yw)z'%s'Nr6   )rK   r  s     r   rM   z"assert_arg_type.<locals>.<genexpr>f  s     $AAVaZ$As   z, got ''z' is expected to be of type 'z', got ')rB   rc   r	   ArgumentErrorrN   rS   )r   argtyper   s      r   assert_arg_typer   _  ss    #w
gu%##$A$AA49N 
 ##$s)- r   c           	          t         j                  r%t         d      rZt         j	                               S t         d      r j                         S t         d      rt         j	                               S t         dt         dd            t        d z        t         d      r fd} |       S t         d	      r"t        fd
 j                         D              S t        d z        )z?Return a (key, value) iterator for almost any dict-like object.r?  	iteritems__getitem__r   NzObject '%r' is not dict-likeiterkeysc               3   P   K   j                         D ]  } |  |       f  y wr   )r  )rh  dictlikegetters    r   iteratorz$dictlike_iteritems.<locals>.iterator  s.     ((* '6#;&&'s   #&rg  c              3   2   K   | ]  }| |      f  y wr   r6   )rK   rh  r  s     r   rM   z%dictlike_iteritems.<locals>.<genexpr>  s     B3S&+&Bs   )
r   r   ra   r   r?  r  iterrU   r   rg  )r  r  r  s   ` @r   r  r  o  s     {{8W%())8[)%%''Xw'())X}ght.LMF~6ABBx$	' z	6	"B(--/BBB6ABBr   c                   (     e Zd ZdZ fdZd Z xZS )classpropertyaA  A decorator that behaves like @property except that operates
    on classes rather than instances.

    The decorator is currently special when using the declarative
    module, but note that the
    :class:`~.sqlalchemy.ext.declarative.declared_attr`
    decorator should be used for this purpose with declarative.

    c                 V    t        t        | 
  |g|i | |j                  | _        y r   )superr  r   r4   )r   r  r   rY  rT   s       r   r   zclassproperty.__init__  s'    mT+D=3="=||r   c                 $    | j                  |      S r   )r  )descr   r=   s      r   r  zclassproperty.__get__  s    yy~r   )r1   r2   r3   r4   r   r  __classcell__rT   s   @r   r  r    s    $r   r  c                       e Zd Zd Zd Zd Zy)hybridpropertyc                      || _         || _        y r   )r   r  r   r   s     r   r   zhybridproperty.__init__  s    	r   c                 N    || j                  |      }|S | j                  |      S r   )r  r   )r   instanceownerclsvals       r   r  zhybridproperty.__get__  s*    ]]5)FM99X&&r   c                     || _         | S r   r%  r  s     r   
classlevelzhybridproperty.classlevel      r   N)r1   r2   r3   r   r  r  r6   r   r   r  r    s    'r   r  c                   "    e Zd ZdZd Zd Zd Zy)hybridmethodz/Decorate a function as cls- or instance- level.c                 .    |x| _         | _        || _        y r   )r   r   r  r  s     r   r   zhybridmethod.__init__  s    $((	DMr   c                     |&| j                   j                  ||j                        S | j                  j                  ||      S r   )r  r  rT   r   )r   r  r  s      r   r  zhybridmethod.__get__  s:    ==((@@99$$Xu55r   c                     || _         | S r   r%  r  s     r   r  zhybridmethod.classlevel  r  r   N)r1   r2   r3   r4   r   r  r  r6   r   r   r  r    s    96r   r  c                   &    e Zd ZddZd Zd Zd Zy)_symbolNc                     t        |t        j                        sJ |t        |      }t        j                  t        |      }||_        |r||_        |S )zConstruct a new named symbol.)	rB   r   rC   hashr  __new__r$  r   r4   )r   r   r   	canonicalvs        r   r'  z_symbol.__new__  sM    $ 3 3444T
IKK+AIr   c                 >    t         | j                  dt        |       ffS )Nr   )r   r   r  r!   s    r   
__reduce__z_symbol.__reduce__  s    		3D	222r   c                     t        |       S r   )r6  r!   s    r   __str__z_symbol.__str__  s    Dzr   c                      d| j                   z  S )Nz
symbol(%r))r   r!   s    r   __repr__z_symbol.__repr__  s    dii''r   NN)r1   r2   r3   r'  r+  r-  r/  r6   r   r   r$  r$    s    	3(r   r$  r   c                   d    e Zd ZdZi Zej                  j                         ZddZ	e
	 dd       Zy)r   a  A constant symbol.

    >>> symbol('foo') is symbol('foo')
    True
    >>> symbol('foo')
    <symbol 'foo>

    A slight refinement of the MAGICCOOKIE=object() pattern.  The primary
    advantage of symbol() is its repr().  They are also singletons.

    Repeated calls of symbol('name') will all return the same instance.

    The optional ``doc`` argument assigns to ``__doc__``.  This
    is strictly so that Sphinx autoattr picks up the docstring we want
    (it doesn't appear to pick up the in-module docstring if the datamember
    is in a different module - autoattribute also blows up completely).
    If Sphinx fixes/improves this then we would no longer need
    ``doc`` here.

    Nc                     | j                   5  | j                  j                  |      }|t        |||      x| j                  |<   }|cd d d        S # 1 sw Y   y xY wr   )_locksymbolsr   r$  )r=   r   r   r(  rt   s        r   r'  zsymbol.__new__  sT    YY 	++//$'C{*1$Y*GGD!C		 	 	s   ;AAc                     |j                         D ]*  \  }}||u r|c S |r||j                  k(  r|c S ||v s(|c S  |yt        j                  d|d|      )a  Given a user parameter, parse the parameter into a chosen symbol.

        The user argument can be a string name that matches the name of a
        symbol, or the symbol object itself, or any number of alternate choices
        such as True/False/ None etc.

        :param arg: the user argument.
        :param choices: dictionary of symbol object to list of possible
         entries.
        :param name: name of the argument.   Used in an :class:`.ArgumentError`
         that is raised if the parameter doesn't match any available argument.
        :param resolve_symbol_names: include the name of each symbol as a valid
         entry.

        NzInvalid value for 'z': )r?  r   r	   r  )r=   r   choicesr   resolve_symbol_namesrt   choices          r   parse_user_argumentzsymbol.parse_user_argument  sg    , #==? 	KCcz
%#/

	 ;c JKKr   r0  r0   )r1   r2   r3   r4   r4  r   r  r  r3  r'  r  r9  r6   r   r   r   r     s@    * G!!#E 6; L  Lr   c                 ,    t         | _         t         dz  a y)zAssign a '_creation_order' sequence to the given instance.

    This allows multiple instances to be sorted in order of creation
    (typically within a single thread; the counter is not particularly
    threadsafe).

    r   N)_creation_order)r  s    r   set_creation_orderr<  "  s      /HqOr   c                 x    	  | |i |S # t         $ r& t        dt        j                         dd z         Y yw xY w)zXexecutes the given function, catches all exceptions and converts to
    a warning.

    z%s('%s') ignoredr   r   N)rE   r(   r   r    )r   r   r.  s      r   warn_exceptionr>  /  sA    
7T$V$$ 7#,,.1"5567s   
 ,99c                 V    	 t        |       |kD  rd| d| z  S | S # t        $ r | cY S w xY w)Nz%s...r   )r	  r   )r*   len_s     r   ellipses_stringrA  :  s=    u:U1T]**L s     ((c                   .     e Zd ZdZ fdZd Zd Z xZS )_hash_limit_stringa/  A string subclass that can only be hashed on a maximum amount
    of unique values.

    This is used for warnings so that we can send out parameterized warnings
    without the __warningregistry__ of the module,  or the non-overridable
    "once" registry within warnings.py, overloading memory,


    c                     ||z  d|z  z   }t         t        |   | |      }t        d|t        |      |z  fz        |_        |S )Nz6 (this warning may be suppressed after %d occurrences)z%s_%d)r  rC  r'  r&  _hash)r=   r*   numr   interpolatedr   rT   s         r   r'  z_hash_limit_string.__new__O  sT    DsJ
 '5c<H'UD,>,D$EEF
r   c                     | j                   S r   )rE  r!   s    r   __hash__z_hash_limit_string.__hash__W  s    zzr   c                 0    t        |       t        |      k(  S r   )r&  )r   others     r   __eq__z_hash_limit_string.__eq__Z  s    DzT%[((r   )r1   r2   r3   r4   r'  rI  rL  r  r  s   @r   rC  rC  D  s    )r   rC  c                 ~    |r!t        t        j                  | |             yt        | t        j                         y)zdIssue a warning.

    If msg is a string, :class:`.exc.SAWarning` is used as
    the category.

    )r   N)_warnings_warnr	   	SAWarning)msgr   s     r   r(   r(   ^  s(     s}}St45sCMM*r   c                 V    |rt        | d|      } t        | t        j                         y)z\Issue a warning with a parameterized string, limiting the number
    of registrations.

    
   N)rC  rN  r	   rO  )rP  r   s     r   warn_limitedrS  k  s#    
  b$/3&r   c                    	 t        j                  |      }|ut        j                  d|j                  j                  dd            rE|j                  }|dz  }|2t        j                  d|j                  j                  dd            rD	 |t        j                  | ||dz          y t        j                  | |dz          y # t        $ r d}Y F d}Y KxY w)Nz^(?:sqlalchemy\.|alembic\.)r1   r  r   r   )
stacklevel)
r   	_getframerO   match	f_globalsr   f_backr  warningsr(   )messagecategoryrU  frames       r   rN  rN  u  s    j) BHH*EOO,?,?
B,O%
 LLE!OJ	 BHH*EOO,?,?
B,O%
 gxJNCg*q.9+   
 
s   C CCc                        g fd}|S )zNDecorate the given function to be a no-op after it is called exactly
    once.c                  t    }rj                         }	  || i |S y #  rj                  d|        xY w)Nr   )r9   insert)r   rY  	strong_fnonce_fnrw   onceretry_on_exceptions       r   gozonly_once.<locals>.go  sM     	hhjG*r** %KK7+s     7r6   )rw   rd  re  rc  s   `` @r   	only_oncerf    s     4D Ir   z%sqlalchemy/([a-z_]+/){0,2}[a-z_]+\.pyzunit(?:2|test2?/)c                    d}t        |       dz
  }||k  r3|j                  | |         r|dz  }||k  r|j                  | |         r||k  r3|j                  | |         r|dz  }||k  r|j                  | |         r| ||dz    S )at  Chop extraneous lines off beginning and end of a traceback.

    :param tb:
      a list of traceback lines as returned by ``traceback.format_stack()``

    :param exclude_prefix:
      a regular expression object matching lines to skip at beginning of
      ``tb``

    :param exclude_suffix:
      a regular expression object matching lines to skip at end of ``tb``
    r   r   )r	  search)tbexclude_prefixexclude_suffixr^   ends        r   chop_tracebackrm    s     E
b'A+C
3,>00E;
 3,>00E;
3,>00C9q 3,>00C9ecAgr   c                 ^    d| z  }t               j                         }t        ||       |d   S )Nz&def set(obj, value):    obj.%s = valuer8   )rq  copyr   )attrnamer   r   s      r   
attrsetterrq    s,    6AD
(--/CsOu:r   c                   (     e Zd ZdZ fdZd Z xZS )EnsureKWArgTypezYApply translation of functions to accept \**kw arguments if they
    don't already.

    c                     | j                   }|rj|D ]e  }t        j                  ||      }|s||   }t        j                  |      }|j
                  rC| j                  |      x||<   }	t        | ||	       g t        t        | +  |||       y r   )ensure_kwargrO   rW  r   r   r   
_wrap_w_kwr&  r  rs  r   )r=   clsnamerr   clsdictfn_regrh  r   rw   r   wrappedrT   s             r   r   zEnsureKWArgType.__init__  s    !! 3HHVS) B!88<D::141CCwS'23 	os,WeWEr   c                 &    fd}t        |      S )Nc                       |  S r   r6   )r   rY  rw   s     r   wrapz(EnsureKWArgType._wrap_w_kw.<locals>.wrap  s    s8Or   r   )r   rw   r}  s    ` r   rv  zEnsureKWArgType._wrap_w_kw  s    	 dB''r   )r1   r2   r3   r4   r   rv  r  r  s   @r   rs  rs    s    
F(r   rs  c                 v   t        |d      rt        | |      S | }|j                  j                  |_        t        |d      r|j                  |_        t        |j
                  d      r3|j
                  j                  r|j
                  j                  |_        |S |j                  r|j                  |_        |S )zAugment functools.update_wrapper() to work with objects with
    a ``__call__()`` method.

    :param fn:
      object with __call__ method

    r1   r2   r4   )ra   r   rT   r1   r2   r   r4   )wrapperrw   _fs      r   wrap_callabler    s     r:gr**ll++2|$MMBM2;;	*r{{/B/B,,BJ 	 ZZBJ	r   c                    d| vr| j                  d      S d}g g}d}t        |       }||k  r}| |   }|dk(  r8|dk(  r-||dz
  k  r%| |dz      dk(  r|d   j                  d       |dz  }n6|dz  }n0|dk(  r|dk(  r|j                  g        n|d   j                  |       |dz  }||k  r}|D cg c]  }dj                  |       c}S c c}w )a  Parse a dotted identifier with accommodation for quoted names.

    Includes support for SQL-style double quotes as a literal character.

    E.g.::

        >>> quoted_token_parser("name")
        ["name"]
        >>> quoted_token_parser("schema.name")
        ["schema", "name"]
        >>> quoted_token_parser('"Schema"."Name"')
        ['Schema', 'Name']
        >>> quoted_token_parser('"Schema"."Name""Foo"')
        ['Schema', 'Name""Foo']

    "r   r   r   r   r  )r   r	  rb   rN   )r*   rU  r  idxlvcharr   s          r   quoted_token_parserr    s    $ %{{3 ETF
C	UB
(Sz3;zcBFluS1W~/Dr
!!#&q
S[UaZMM"2Jd#q ( )//uBGGEN///s   .C	c                 @     t        j                           fd}|S )Nc                     | j                   d uxr | j                   xs d}|rt        |D ci c]  }| c}      }|| _         | S c c}w )Nr  )r4   inject_param_text)rw   r   paramparamsr  s      r   r   z$add_parameter_text.<locals>.decorate-  sO    jj$39r#C6)J%%+)JKC
	 *Ks   
A
)r   r;  )r  r  r   s   `` r   add_parameter_textr  *  s    !!&)F Or   c                     | j                  dd      }t        |      dk(  r| S |\  }}|j                  d      s|dz   t        j                  |      z   S t        j                  |       S )Nr&   r   r%   )r   r	  ro  textwrapdedent)r  
split_text	firstline	remainings       r   _dedent_docstringr  7  sc    D!$J
:!)	9$4(//)"<<<t$$r   c                    t        | xs d      } | j                  d      }t        |      dk(  r|j                  d       t	        j
                  |      j                  d      }|d   r|j                  dd       t        |      D cg c]  \  }}|j                         r| }}}|j                  dd       |t        |t        |      dz
           }|d| |z   ||d  z   }dj                  |      S c c}}w )Nr  r&   r   r   )r  r   r	  rb   r  r  r`  r=  r  minrN   )	doctext
injecttextposlinesinjectlinesrF  lineblanks
inject_poss	            r   r   r   C  s    2.GMM$E
5zQR//*-33D9K1~1b!#,U#3Hic44::<cHFH
MM!QCVq12J!J+-jk0BBE99U Is   	C5"C5z(\s+):param (.+?):c                    t        j                  | j                               }g }d }|r9|j                         }t        j                  |      }||r|j                  d      j                  d      }||v rdt        |j                  d            z  dz   }|r8t        j
                  d|d         }	|	rdt        |	j                  d            z  }|||   z   }nt|r|j                  d|dg       d }n[|j                         s|j                  ||dg       d }n4|j                  d      r#|j                  ||j                         g       '|j                  |       |r9dj                  |      S )	Nr   *r%   r   z(\s+)\Sr   r&   z::)collectionsdeque
splitlinespopleft
_param_regrW  r   lstripr	  rO   r;   rstriprp  rb   rN   )
r  inject_paramsdoclinesr  	to_injectr  r   r  indentm2s
             r   r  r  X  sX     !3!3!56HE I
!T"
))#.M) 3qwwqz?2S8F  XXj(1+>%(3rxx{+;%;F &u)= =ILL$	401ILL$	401I]]4  LL$ 0 0 234T? B 99Ur   c                    t        |       dk(  ryt        |       dk  }|r| dd n
| dd | dd z   } | D cg c]  }t        |      dkD  rd|dd z  n| }}|rdj                  |      S dj                  |dd       d	|d   S c c}w )
zTrims a list of strings from the middle and return a string of up to
    four elements. Strings greater than 11 characters will be truncatedr   Nr   r|   r      z%s..r9  z, ..., )r	  rN   )r   flagr   ress       r   repr_tuple_namesr    s     5zQu:?DE!AJE!AJrs$;EFK
LdTR6D"IT9
LC
Lyy~ $		#a( 3SW==	 Ms   Bc                  H    	 ddl m}  ddl m} ddl m} y# t        $ r Y yw xY w)Nr   )cimmutabledict)cprocessors)cresultproxyTF)r   r  r  r  r   )r  r  r  s      r   has_compiled_extr    s%    -*+ s    	!!r   )FF)T)r6   r6   r6   )r6   Nr6   )NNz
self.proxyN)NNN)TN)   )Nr   )ar4   r  	functoolsr   r   r   rl   r  rO   r   r  r   rZ  r  r   r   r	   r   r  r   r@   rG   rQ   r[   rf   ru   ry   r   r   r   r   r   r   r   r   r   r   r  r,  r/  r3  rM  rO  rd  ri  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  propertyr  r  r  r  r$  r1   r   r;  r<  r>  rA  	text_typerC  r(   rS  rN  rf  compile_SQLA_RE_UNITTEST_RErm  rS   NoneTyperq  rs  r  r  r  r  r   r  r  r  r  r6   r   r   <module>r     s}  
  $     	 
      .;6 .;b6,M  ,F*
Tn# 6 # L
((V23;lm
`J qh6$	EBP;f ;<0f& 
		</~Sl% %,'.9+& 9+x%/F %/R	'(B C:H &V "6 $(c (,  ALV ALH 
7))) )4
+'::, 2::>?rzz./ '38 , :(d (40)0X
	%$ RZZ-.
(V>r   