
    -h                        S r SSKrSSKJr  SSKrSSKrSSKrSSKrSSKrSSK	r	SSK
r
SSKrSSKrSSKJr  SSKJr  SSKJr  S	 r " S
 S\5      rS rS rS rS rS rS rS rS rS rS rS]S jr " S S\5      rS r S]S jr!S r"S^S jr#S_S jr$S_S jr%   S`S jr&S  r'S! r(SaS" jr) " S# S$\5      r*S% r+S& r,    SbS' jr-S( r.ScS) jr/ " S* S+\5      r0S, r1 " S- S.\5      r2 " S/ S0\5      r3S1 r4S2 r5S3 r6SdS4 jr7S5 r8S6 r9S7 r:S]S8 jr;S9 r<S: r= " S; S<\>5      r? " S= S>\5      r@ " S? S@\5      rA " SA SB\B5      rCSC\ClD         " SD SC\5      rESqFSE rGSF rHSeSG jrI " SH SI\R                  5      rKS]SJ jrLSK rMSfSL jrNSM rO\R                  " SN5      rQ\R                  " SO5      rR\R\Q4SP jrS\T" S5      rUSQ rV " SR SS\T5      rWST rXSU rYSV rZSW r[SX r\\R                  " SY5      r]SZ r^S[ r_S\ r`g)gzRoutines to help with the creation, loading and introspection of
modules, classes, hierarchies, attributes, functions, and methods.

    Nupdate_wrapper   )_collections)compat   )excc                     [         R                  (       a  U R                  S5      n [        R                  " 5       nUR                  U 5        UR                  5       $ )Nzutf-8)r   py3kencodehashlibmd5update	hexdigest)xms     pC:\Users\ROHAN GUPTA\OneDrive\Desktop\mathbuddy-assessment\venv\Lib\site-packages\sqlalchemy/util/langhelpers.pymd5_hexr      s9    {{HHWAHHQK;;=    c                   2    \ rS rSrSrSrS	S jrS rS rSr	g)
safe_reraise&   a  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                     Xl         g N)r   )selfr   s     r   __init__safe_reraise.__init__:   s    "r   c                 8    [         R                  " 5       U l        g r   )sysexc_infor   r   s    r   	__enter__safe_reraise.__enter__=   s    r   c                    Uc>  U R                   u  pEnS U l         U R                  (       d  [        R                  " UUS9  g g [        R                  (       dS  U R                   (       aB  U R                   S   (       a.  [        SU R                   S   < SU R                   S   < S35        S U l         [        R                  " X#S9  g )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__safe_reraise.__exit__@   s    =*...'H!DN>>#) " ;;4>>dnnQ6G  (,~~a'8$..:KM
 "DNMM%:r   )r   r   NF)
__name__
__module____qualname____firstlineno____doc__	__slots__r   r$   r2   __static_attributes__ r   r   r   r   &   s    " +I#(;r   r   c              #      #    [        5       nU /nU(       aU  UR                  5       n X;   a  M  UR                  U 5        UR                  U R	                  5       5        U v   U(       a  MT  g g 7fr   )setpopaddextend__subclasses__)clsseenstacks      r   walk_subclassesrF   W   sU     5DEE
iik;HHSMS'')*	 %s   A'A-+A-c                     [        U [        R                  5      (       a  U $  [        U 5      $ ! [         a    SU -  s $ f = f)Nzunprintable element %r)
isinstancer   string_typesstr	Exception)elements    r   string_or_unprintablerM   e   sC    '6..//	6w< 	6+g55	6s   
. A A c                 p    SR                  S [        R                  " SU R                  5       5       5      $ )Nr(   c              3   @   #    U  H  oR                  5       v   M     g 7fr   )lower).0ns     r   	<genexpr>(clsname_as_plain_name.<locals>.<genexpr>p   s      Ea		Es   z([A-Z][a-z]+))joinrefindallr5   )rC   s    r   clsname_as_plain_namerX   o   s0    88 ::&6E  r   c                     [        U [        5      (       d  U R                  nOU nUR                  n[	        X#5      nXA:g  $ )z1Return True if the two class methods don't match.)rH   type	__class__r5   getattr)instance_or_clsagainst_methodcurrent_clsmethod_namecurrent_methods        r   method_is_overriddenrb   u   s?     ot,,%//% ))K[6N++r   c                     / nU R                   U R                  U R                  4 H5  n[        US5      (       a  UR	                  5       nUR                  U5        M7     [        U5      $ )zjdecode a slice object as sent to __getitem__.

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

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

1 + :r   c           
   '     ^#    [        U 5      n U Ho  m[        R                  " T4[        R                  " U4S j[        S5      5      5      nU H   nX0;  d  M
  U R                  U5        Uv     Ma     [        ST-  5      e   g 7f)Nc                     > T[        U 5      -   $ r   )rJ   )ibases    r   <lambda>!_unique_symbols.<locals>.<lambda>   s    D3q6Mr   i  z&exhausted namespace for symbol base %s)r>   	itertoolschainr   itertools_imapranger@   	NameError)usedbasespoolsymrq   s       @r   _unique_symbolsr}      sx     t9DG!!"95;G
 C		  DtKLL s   AB+Bc              #   Z   #    U(       a   X) S-   -  nU " U5      v   X-  nU(       a  M  gg7f)z6Call the given function given each nonzero bit from n.r   Nr<   )fnrR   bs      r   map_bitsr      s.      aLe	 !s   %++c                 (   ^  U 4S jn[        UT 5      $ )z'A signature-matching decorator factory.c                 `  > [         R                  " U 5      (       d&  [         R                  " U 5      (       d  [        S5      e[        R
                  " U 5      n0 n[        X5      n[        US   5      USS -   U R                  4-   n[        USS5      u  pE[        XES9nUR                  [        USS	95        U R                  US
'   SU-  nUR                  UT	XPSU R                  05        [        XrU R                  5      n[        U SU 5      R                   Ul        Xl        [%        X5      $ )Nznot a decoratable functionr   r      targetr   )r   r   FgroupednamezDdef %(name)s(%(args)s):
    return %(target)s(%(fn)s, %(apply_kw)s)
r5   __func__)inspect
isfunctionismethodrK   r   inspect_getfullargspec!_update_argspec_defaults_into_envrj   r5   r}   dictr   format_argspec_plusr6   _exec_code_in_envr\   __defaults____wrapped__r   )
r   specenvnames	targ_namefn_namemetadatacode	decoratedr   s
            r   decoratedecorator.<locals>.decorate   s   !!"%%g.>.>r.B.B899,,R00;d1ga*bkk^;,UHdC	y5+D%@A;; 	 	 	

IvwJNO%d=	!(Z!<!I!I	 "i,,r   r   )r   r   s   ` r   	decoratorr      s    -: (F++r   c                 D   U R                   (       a  / nSnU R                    HN  n[        U5      R                  S;  a!  SU-  nXAU'   UR                  U5        US-  nM=  UR                  U5        MP     [	        U 5      n[        U5      US'   [        R                  " U6 $ U $ )zCgiven a FullArgSpec, convert defaults to be symbol names in an env.r   )builtins__builtin__zx%dr   r   )defaultsrZ   r6   ri   listrj   r   FullArgSpec)r   r   new_defaultsrp   argr   elems          r   r   r      s     }}==CCy##+FFqyD	##D)Q##C( ! Dz%Q!!4((r   c                      [        X5        X   $ r   )exec)r   r   r   s      r   r   r      s    O<r   c           
         [        U [        5      (       a0  U R                  nU nSU(       a  UOSU R                  -  < SU< S3nOU =p4SU-  nUR	                  S5      S   n[
        R                  " U5      nUS   S	 [        US	S
9nXhS'   SU-  n	U[        UR                  S.n
[        X5        X   n[        US5      (       a[  UR                  u  pUR                  nUc  U R                  < SU R                  < 3n[        USU< SU< SU< S3S5      nXl        OUR                  Ul        SUR                  SS5      S   -   Ul	        UR                  [         R"                  ;  a  [%        SUR                  < S35      e[
        R&                  (       d  [        US5      (       a?  XSR(                  l        [        UR(                  S5      (       d  X4UR(                  l        U$ XSl        [        US5      (       d  X4Ul        U$ )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)
)rC   symbolr5   
_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   )rH   rZ   r   r5   splitr   r   r   r   r6   r   rh   r   r9   inject_docstring_textrsplitr!   modulesImportErrorpy2kr   )r   locationclass_locationr   	callable_doclocation_namer   r   r   r   r   	linked_tolinked_to_locationlinked_to_docs                  r   public_factoryr      s    &$__	 #1efoo6MM 	  .089 	
 NN3'+M((,DQ
"47H$V	 		 	 ((C
 	O"Ir<  (*%	!))!(.(9(96??KN- "8^= 	
 *JJ	'(//#q*A!*DDI3;;.##&
 	

 {{gb*--!r{{L11&/%:BKK" 	 
r<((&1BMr   c                   0    \ rS rSrSS jrS rS rS rSrg)	PluginLoaderi?  Nc                 *    Xl         0 U l        X l        g r   )groupimplsauto_fn)r   r   r   s      r   r   PluginLoader.__init__@  s    

r   c                 8    U R                   R                  5         g r   )r   clearr#   s    r   r   PluginLoader.clearE  s    

r   c                    XR                   ;   a  U R                   U   " 5       $ U R                  (       a-  U R                  U5      nU(       a  X R                   U'   U" 5       $ [        R                  " U R                  5       H>  nUR
                  U:X  d  M  UR                  U R                   U'   UR                  5       s  $    [        R                  " SU R                  < SU< 35      e)NzCan't load plugin: :)	r   r   r   importlib_metadata_getr   r   loadr	   NoSuchModuleError)r   r   loaderimpls       r   r   PluginLoader.loadH  s    ::::d#%%<<\\$'F#)

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

4 yy{" >
 ##*.**d;
 	
r   c                 2   ^^ UU4S jnX@R                   U'   g )Nc                     > [         R                  " T5      n TR                  S5      SS   H  n[        X5      n M     [        U T5      $ )Nr   r   )r   import_r   r\   )modtoken
modulepathobjnames     r   r   #PluginLoader.register.<locals>.load\  sD    ..,C#))#.qr2c) 33((r   )r   )r   r   r   r   r   s     `` r   registerPluginLoader.register[  s    	)  

4r   )r   r   r   r   )	r5   r6   r7   r8   r   r   r   r   r;   r<   r   r   r   r   ?  s    

& r   r   c                 &    [         R                  nU R                  nUR                  n[	        UR
                  S U 5      [        UR                  U-  5      4$ ! [         a,    [        R                  " U 5      nUS   [        US   5      4s $ f = f)Nr   r   )r   CO_VARKEYWORDS__code__co_argcountr   co_varnamesboolco_flagsAttributeErrorr   r   )r   co_varkeywordsconargsr   s        r   _inspect_func_argsr   e  s    
 // [['(~-.
 	
  &
 ,,R0AwT!W%%&s   A 3BBc                    USL nU(       a
  [        5       nU R                  R                  SS5      nU=(       aE    [        U[        R
                  5      =(       a$    [        UR                  [        R                  5      nU(       a-  [        U5      u  pVUR                  U5        U(       d  U(       d  gU(       a  W(       a!  U R                   H  n[        Xq5      b  M    O   UR                  S5        U$ )aA  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   )r>   __dict__getrH   typesFunctionTyper   CodeTyper   r   	__bases__get_cls_kwargsdiscard)rC   _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/EhvAa&.  	LLKr   c                 4    [         R                  " U 5      S   $ )zwReturn 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           	         [         R                  " U 5      (       a  [        SU -  5      e[         R                  " U 5      (       a  U(       a  U(       a{  [        R
                  " U 5      n[        R                  " UR                  SS UR                  UR                  UR                  UR                  UR                  UR                  5      $ [        R
                  " U 5      $ [         R                  " U 5      (       a  U(       a  U(       d  U R                  (       a  [        R
                  " U R                   5      n[        R                  " UR                  SS UR                  UR                  UR                  UR                  UR                  UR                  5      $ [        R
                  " U R                   5      $ [         R"                  " U 5      (       a  [%        U R&                  USS9$ [)        U S5      (       a   [        R
                  " U R                   5      $ [)        U S5      (       aG  [         R                  " U R*                  5      (       a  [%        U R*                  US9$ [        S	U -  5      e[        S	U -  5      e)
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   rh   r   )r   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           
      0   [         R                  " U 5      (       a  [         R                  " U 5      nOU n[         R                  " U6 n[         R                  " US   US   US   SUS   5      nUS   (       a2  US   S   n[         R                  " US   SS US   US   SUS   5      nOUS   (       a  SUS   -  nUnOSnUnSnUS   (       a  U[	        US   5      -  nUS   (       a  U[	        US   5      -  nUS   US   -   nU(       a	  USU-
  S n	OSn	[         R                  " UUS   US   U	S	 S
9n
US   (       a#  [         R                  " USS US   US   U	S S
9nOU
nU(       a  [        UUUU
UUS9$ [        USS UUSS U
SS USS USS S9$ )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   r<   c                     SU -   $ N=r<   r   s    r   rr   %format_argspec_plus.<locals>.<lambda>3  s    cAgr   )formatvaluec                     SU -   $ r  r<   r  s    r   rr   r  <  s    #'r   )r   self_arg	apply_posapply_kwapply_pos_proxiedapply_kw_proxiedr   )r   callabler   inspect_formatargspeclenr   )r   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           	          U [         R                  L a  U(       a  SOSnU(       a  SOSnO
 [        XS9$ [	        SUUUUUS
9$ ! [         a    U(       a  SOSnU(       a  SOS	n N0f = f)zformat_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&v?? !    	L  *, 
 .5):KG	Ls   A  A&%A&c                 (   ^ ^^^^^ UUUUU U4S jnU$ )zA class decorator that will copy attributes to a proxy class.

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

c           
        > SUU	U
4S jjnUU	U
4S jnT H8  n[        X5      (       a  [        SU < SU< 35      e[        XU" U5      5        M:     T H8  n[        X5      (       a  [        SU < SU< 35      e[        XU" U5      5        M:     T H7  n[        X5      (       a  [        SU < SU< 35      e[        XU" USS95        M9     U $ )Nc                   > [        T
U 5      n[        R                  " U5      nSUR                  0n[	        X45      n[        USS9nUR                  US   US   US   US   S.nU(       a  S	U-  nT
US
'   OSU-  n[        XtUR                  5      n[        USU5      R                  Ul        [        UR                  ST< ST	< S3S5      Ul
        U(       a  [        U5      nU$ )Nr5   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   )r\   r   r   r6   r   r   r5   r   r   r   r9   classmethod)r   clslevelr   r   r   caller_argspecr   r   proxy_fnproxy_cls_sphinx_namer%  target_cls_sphinx_names            r   
instrument:create_proxy_methods.<locals>.decorate.<locals>.instrument  s   T*B004Dr}}-C4T?D0uEN %34G%H$23E$F&v.*:6H K 
 %/L!V  )BKK@H$+B
B$?$L$LH!4

 *+@B  H &x0Or   c                    > TR                   R                  U S 5      nUb!  [        UR                  ST< ST< S3S5      nOS nSSU 0-  n[	        USU0S5      nU$ )	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   r9   r   )r   attrr   r   r2  r-  r%  r.  s        r   makeprop8create_proxy_methods.<locals>.decorate.<locals>.makeprop  sy    &&**46D+LL /-	 	 / D 'teS\8DFMr   zclass z already has a method Tr*  r4   )rh   r   setattr)rC   r/  r4  methprop
attributesclassmethodsmethodsr-  r%  r.  s        r   r   &create_proxy_methods.<locals>.decorate  s    +	 +	Z	< Ds!!:=tD  Cz$/0  Ds!!:=tD  Cx~.  !Ds!!:=tD  Cz$>? ! 
r   r<   )r%  r.  r-  r;  r<  r:  r   s   `````` r   create_proxy_methodsr>  v  s    a aF Or   c                      [         R                  " U 5      $ ! [         a&    U [        R                  L a	  S/SSS4s $ S/SSS4s $ f = f)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_initrA    sU    6,,V44 6V__$HdD$//Hfh55	6s    $AAAc                 ~    [        U [        R                  5      (       a  U R                  (       d  U R                  $ U $ )zKAdjust the incoming callable such that a 'self' argument is not
required.

)rH   r   
MethodTyper  r   )func_or_clss    r   unbound_method_to_callablerE    s1     +u//009M9M###r   c           	        ^  Uc  T /nO[         R                  " U5      n[        5       n/ n[         R                  " 5       nSn[	        U5       GHE  u  p [
        R                  " U	R                  5      n
U
R                  =(       a    [        U
R                  5      =(       d    SnUS:X  ac  U
R                  (       a  U
R                  nU(       a   UR                  U
R                  SU*  5        OPUR                  U
R                  SS 5        O1UR                  U
R                  SU*   Vs/ s H  oU4PM     sn5        U(       aL  UR                  [        U
R                  U* S U
R                  5       VVs/ s H  u  pX4PM
     snn5        GME  GMH     / nUR                  U 4S jU 5       5        UbF  [!        T U5      (       a5  UR                  [#        T U5       Vs/ s H  n[%        U5      PM     sn5        UR'                  5        H@  u  nnX;   a  M   [#        T X5      nXLa"  UU:w  a  UR)                  U< SU< 35        M>  M@  MB     U(       a?  U H9  u  nn [#        T X5      nXLa"  UU:w  a  UR)                  U< SU< 35        M7  M9  M;     T R,                  R.                  < SSR1                  U5      < S3$ s  snf s  snnf ! [         a     GM  f = fs  snf ! [*         a     M  f = f! [*         a     M  f = f)	zuProduce a __repr__() based on direct association of the __init__()
specification vs. same-named attributes present.

Nr   r   c              3   P   >#    U  H  n[        [        TUS 5      5      v   M     g 7fr   )reprr\   )rQ   r   objs     r   rS   generic_repr.<locals>.<genexpr>5  s"     D8C$wsC.//8s   #&r  (, ))r   to_listr  OrderedDict	enumerater   r   r   r   r  r   rA   r   r   zipr   rh   r\   rH  itemsri   rK   r[   r5   rU   )rI  additional_kw
to_inspect
omit_kwargmissingpos_argskw_argsvargsrp   inspr   default_lenr   defaultoutputvaldefvals   `                r   generic_reprr`    s   
 U
!))*5
hGH&&(GEZ(	00?D -->C,>C!KAv<< LLEOODIIa$=>OODIIabM2/3yyK</HI/H7^/HI  -0 II{lm4dmm--LC - ' )8 F
MMD8DDWS%00GC,?@,?StCy,?@A}}V	#s,C!cVmc23 '4! ' (KCc30%#-MMS#"67 +8% ) }}--tyy/@AAM J
%  		< A  		  sH    K+K
8K	!K!.K&!.K7
KK&
K43K47
LLc                   8    \ rS rSrSrSrS rS rS
S jrS r	Sr
g	)portable_instancemethodiP  zWTurn an instancemethod into a (parent, name) pair
to produce a serializable callable.

)r   r   r@  __weakref__c                 J    U R                   U R                  U R                  S.$ )Nr   r   r@  re  r#   s    r   __getstate__$portable_instancemethod.__getstate__X  s!    kkIIkk
 	
r   c                 Z    US   U l         US   U l        UR                  SS5      U l        g )Nr   r   r@  r<   )r   r   r   r@  )r   states     r   __setstate__$portable_instancemethod.__setstate___  s*    Ho&M	ii"-r   c                 T    UR                   U l        UR                  U l        X l        g r   )r  r   r5   r   r@  )r   r8  r@  s      r   r    portable_instancemethod.__init__d  s    mmMM	r   c                     UR                  U R                  5        [        U R                  U R                  5      " U0 UD6$ r   )r   r@  r\   r   r   )r   r   kws      r   r    portable_instancemethod.__call__i  s1    
		$++t{{DII.:r::r   )r@  r   r   N)r<   )r5   r6   r7   r8   r9   r:   rf  rj  r   r   r;   r<   r   r   rb  rb  P  s"    
 :I
.

;r   rb  c                   ^ [         R                  (       a)  [        U [        R                  5      (       a
  [        5       $ U 1m[        U R                  5      nU(       GaV  UR                  5       n[         R                  (       a8  [        U[        R                  5      (       a  MN  U4S jUR                   5       nOU4S jUR                   5       nU H%  nUR                  U5        TR                  U5        M'     [         R                  (       a$  UR                  S:X  d  [        US5      (       d  M  O$UR                  S:X  d  [        US5      (       d  GM  UR                  5        Vs/ s H  oUT;  d  M
  UPM     sn H%  nUR                  U5        TR                  U5        M'     U(       a  GMV  [        T5      $ s  snf )aj  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   z   >#    U  H0  nUT;  d  M  [        U[        R                  5      (       a  M,  Uv   M2     g 7fr   )rH   r   	ClassTyperQ   _hiers     r   rS   "class_hierarchy.<locals>.<genexpr>  s4      $AD= )3Au)G $s   
;;	;c              3   6   >#    U  H  oT;  d  M
  Uv   M     g 7fr   r<   rt  s     r   rS   rw    s     =1}QQs   		r   rB   r   )r   r   rH   r   rs  r   __mro__r?   r   ri   r@   r   r6   rh   rB   )rC   processr   rz   r   ru  srv  s          @r   class_hierarchyr|  n  sO    {{c5??++6M5D3;;G
KKM;;!U__--E >=EANN1HHQK  ;;||z)<L1M1M 2N ||},G#5 5 --/A/D=!/AANN1HHQK B5 ': : Bs   -	G:Gc              #      #    [        U 5      nU H:  nU R                   H'  nX#R                  ;   d  M  X#R                  U   4v     M8     M<     g7f)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)dirry  r   )rC   keyskeyr   s       r   iterate_attributesr    sF      s8DAjj JJsO,,  s
   -AAc                    U(       a  UnOiUc  Sn[        U5       Vs/ s HN  nUR                  S5      (       d  M  UR                  S5      (       d  M3  [        X5      (       a  ME  Xr;  d  ML  UPMP     nnU H  n [	        X5      n	[        U	S5      (       d  M"  [	        U	SU	5      n	 [        R                  " U	5      n
[        R                  " U
S   5      n[        R                  " U
S   SS 5      nS
[        5       -  nUSL=(       a    XE0=(       d    0 n[        R                  " X5         U	R                  X   l        [        XX   5        M     gs  snf ! [
         a     M  f = f! [         a    SnS	n Nf = f! [
         a     NIf = f)z9Automates delegation of __specials__ for a proxying type.N)r:   __del____getattribute____metaclass__rf  rj  __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)r~  
startswithendswithrh   r\   r   r   r   r  r   localsexec_r   r7  )into_clsfrom_clsskiponlyr   from_instancedundersr   r  r   r   fn_argsd_argspyr   s                  r   monkeypatch_proxied_specialsr    s    <D ]	
"T"  JJt$	 
  ,  M " 	 	
 	*B2z**Z,B	%004D2247;G11$q'!"+>F35;X> 	
 4'AT,AGRR	')CK$ 	#+.7 	
"  		  	%+G$F	%  		sY   EEE%E,E:EE&AE(,E<
E%$E%(E98E9<
F	F	c                 6    [        U SU 5      [        USU5      L $ )z;Return True if the two methods are the same implementation.r   )r\   )meth1meth2s     r   methods_equivalentr    s(     5*e,z51  r   c           	         U(       d  U(       d  [        S5      e[        U[        5      (       a  [        X5      (       a  U $ [        U=(       d3    [	        U5       Vs/ s H  oDR                  S5      (       a  M  UPM     sn5      n[        [	        U 5      5      n[        R                  n[        U[        5      (       a  UnO-U(       d  [        5       n[        R                  nO[        U5      nU" UR                  U5      U5      (       a  U $ [        U [        5      (       dI  U[        R                  L =(       a    S=(       d    Sn[        U < SU< SSR                  U5      < 35      e " S S	[        5      n	U(       a  S
UR                  -   U	l        [        5       n
[        U 5       Hl  u  pX;  a  [        SU-  5      e[        R                   " U5      (       d  [        U< SU< S35      e[#        X[%        U5      5        U
R'                  U5        Mn     U" X5      (       a  U	$ [        SSR                  X:-
  5      -  5      es  snf )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 requiredru  zany ofzall ofz does not implement z: rL  c                       \ rS rSrSrSrg)(as_interface.<locals>.AnonymousInterfacei6  zA callable-holding shell.r<   N)r5   r6   r7   r8   r9   r;   r<   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   rH   rZ   r>   r~  r  operatorgegtintersectionr   rU   r  r5   dictlike_iteritemsr   r  r7  staticmethodr@   )rI  rC   r<  requiredr   	interfaceimplementedcomplies	qualifierr  foundr  r   s                r   as_interfacer    s   B wLMM#tC!5!5
GM3s8M8a<<;L8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"L,>?		& 0   !!
6
))H$
%	& S  Ns   I	9I	c                   >    \ rS rSrSrS	S jrS rS r\S 5       r	Sr
g)
memoized_propertyiN  z2A read-only @property that is only evaluated once.Nc                 f    Xl         U=(       d    UR                  U l        UR                  U l        g r   fgetr9   r5   r   r  r   s      r   r   memoized_property.__init__Q  s"    	*dllr   c                 d    Uc  U $ U R                  U5      =UR                  U R                  '   nU$ r   )r  r   r5   r   rI  rC   results       r   __get__memoized_property.__get__V  s0    ;K/3yy~=T]]#fr   c                 B    [         R                  XR                  5        g r   )r  resetr5   )r   rI  s     r   _resetmemoized_property._reset\  s    ]]3r   c                 <    UR                   R                  US 5        g r   )r   r?   )rC   rI  r   s      r   r  memoized_property.reset_  s    t$r   r9   r5   r  r   )r5   r6   r7   r8   r9   r   r  r  r)  r  r;   r<   r   r   r  r  N  s(    <&
4 % %r   r  c                 (   ^  U 4S jn[        UT 5      $ )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                    >^ T" U /UQ70 UD6mU4S jnTR                   Ul         TR                  Ul        X0R                  TR                   '   T$ )Nc                     > T$ r   r<   aro  r  s     r   memo6memoized_instancemethod.<locals>.oneshot.<locals>.memop  s    Mr   )r5   r9   r   r   r   ro  r  r  r   s       @r   oneshot(memoized_instancemethod.<locals>.oneshotm  sI    D&4&2&	 zz%)bkk"r   r   )r   r  s   ` r   memoized_instancemethodr  d  s    	 '2&&r   c                   b    \ rS rSrSrSr\" 5       rS rS r	S r
 " S S\5      r\S	 5       rSrg
)HasMemoizedi{  zqA class that maintains the names of memoized elements in a
collection for easy cache clearing, generative, etc.

r<   c                 b    U R                    H  nU R                  R                  US 5        M!     g r   )_memoized_keysr   r?   r   r   s     r   _reset_memoizationsHasMemoized._reset_memoizations  s&    ''DMMdD) (r   c                 L    U R                    H  nXR                  ;  a  M   e   g r   )r  r   r  s     r   _assert_no_memoizations#HasMemoized._assert_no_memoizations  s"    ''D}},,, (r   c                 L    X R                   U'   U =R                  U1-  sl        g r   )r   r  )r   r  r-   s      r   _set_memoized_attribute#HasMemoized._set_memoized_attribute  s!    "cu$r   c                   (    \ rS rSrSrSS jrS rSrg)HasMemoized.memoized_attributei  zDA read-only @property that is only evaluated once.

:meta private:

Nc                 f    Xl         U=(       d    UR                  U l        UR                  U l        g r   r  r  s      r   r   'HasMemoized.memoized_attribute.__init__  s"    I.$,,DL MMDMr   c                     Uc  U $ U R                  U5      =UR                  U R                  '   nU=R                  U R                  1-  sl        U$ r   )r  r   r5   r  r  s       r   r  &HasMemoized.memoized_attribute.__get__  sG    {3799S>ACLL'&4==/1Mr   r  r   )r5   r6   r7   r8   r9   r   r  r;   r<   r   r   memoized_attributer    s    		*
	r   r  c                 (   ^ U4S jn[        UT5      $ )z+Decorate a method memoize its return value.c                    >^ T" U /UQ70 UD6mU4S jnTR                   Ul         TR                  Ul        X0R                  TR                   '   U =R                  TR                   1-  sl        T$ )Nc                     > T$ r   r<   r  s     r   r  BHasMemoized.memoized_instancemethod.<locals>.oneshot.<locals>.memo  s    r   )r5   r9   r   r  r  s       @r   r  4HasMemoized.memoized_instancemethod.<locals>.oneshot  s`    *t*r*F KKDM::DL)-MM"++&BKK=0Mr   r   )rC   r   r  s    ` r   r  #HasMemoized.memoized_instancemethod  s    
	 gr**r   N)r5   r6   r7   r8   r9   r:   	frozensetr  r  r  r  r  r  r)  r  r;   r<   r   r   r  r  {  sD    
 I[N*-%V & + +r   r  c                   (    \ rS rSrSrSrS rS rSrg)MemoizedSlotsi  zApply 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__.

r<   c                     [        U5      er   )r   )r   r  s     r   _fallback_getattrMemoizedSlots._fallback_getattr  s    S!!r   c                 V  ^ ^^ TR                  S5      (       a  [        T5      e[        T ST-  5      (       a#  [        T ST-  5      " 5       n[	        T TU5        U$ [        T ST-  5      (       a*  [        T ST-  5      mUUU 4S jnTR
                  Ul        U$ T R                  T5      $ )N	_memoizedz_memoized_attr_%sz_memoized_method_%sc                     >^ T" U 0 UD6mU4S jnTR                   Ul         TR                  Ul        [        TTU5        T$ )Nc                     > T$ r   r<   r  s     r   r  8MemoizedSlots.__getattr__.<locals>.oneshot.<locals>.memo  s    !Mr   )r5   r9   r7  )r   ro  r  r  r   r  r   s      @r   r  *MemoizedSlots.__getattr__.<locals>.oneshot  s>    TR" !#!zzc4(r   )r  r   rh   r\   r7  r9   r  )r   r  r-   r  r   s   ``  @r   __getattr__MemoizedSlots.__getattr__  s    >>+&& %%T.455D"5";<>ED#u%LT036774s:;B	 !jjGON))#..r   N)	r5   r6   r7   r8   r9   r:   r  r  r;   r<   r   r   r  r    s     I"/r   r  c                     [        U [        R                  5      (       a:  U R                  5       R	                  5       n U S;   a  gU S;   a  g[        SU -  5      e[        U 5      $ )N)trueyesonyt1T)falsenooffrR   f0FzString is not true/false: %r)rH   r   rI   striprP   
ValueErrorr   )rI  s    r   asboolr    s\    #v**++iik!6699;cABB9r   c                     ^  U 4S jnU$ )ziReturn a callable that will evaluate a string as
boolean, or one of a set of "alternate" string values.

c                 *   > U T;   a  U $ [        U 5      $ r   )r  )rI  texts    r   bool_or_value"bool_or_str.<locals>.bool_or_value  s    $;J#;r   r<   )r  r  s   ` r   bool_or_strr    s     r   c                 "    U c  U $ [        U 5      $ )zCoerce to integer.)int)r-   s    r   asintr    s     }u:r   c                     Uc  U nX;   a\  [        U[        5      (       a  [        X   U5      (       d3  X   b-  U[        L a  U(       a  [        X   5      XA'   gU" X   5      XA'   gggg)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)rH   rZ   r   r  )ro  r  r,   
flexi_booldests        r   coerce_kw_typer    sk     | 		E4((
27E0J0JGD=ZrwDIbgDI   1K 	r   c                 L   ^  [        U5      nU4[        U 4S jU 5       5      -   $ )zZProduce a tuple structure that is cacheable using the __dict__ of
obj to retrieve values

c              3   h   >#    U  H'  oTR                   ;   d  M  UTR                   U   4v   M)     g 7fr   r   rQ   krI  s     r   rS   "constructor_key.<locals>.<genexpr>  s-      &+CLL/@CLLOe   22)r   rj   )rI  rC   r   s   `  r   constructor_keyr    s2    
 3E6E &+   r   c                 ~   ^  [        U5      nUR                  U 4S jUR                  U5       5       5        U" U0 UD6$ )z|Instantiate cls using the __dict__ of obj as constructor arguments.

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

c              3   h   >#    U  H'  oTR                   ;   d  M  UTR                   U   4v   M)     g 7fr   r  r  s     r   rS   #constructor_copy.<locals>.<genexpr>*  s.      &:3<<>OCLLO&:r  )r   r   
difference)rI  rC   r   ro  r   s   `    r   constructor_copyr  "  sE     3EII &+&6&6r&:  r   c                     ^^ [         R                  R                  5       m[        R                  " S5      mUU4S jn U $ )z%Return a threadsafe counter function.r   c                  T   > T   [        T 5      sS S S 5        $ ! , (       d  f       g = fr   )next)counterlocks   r   _nextcounter.<locals>._next7  s    = TTs   
')r   	threadingLockrt   count)r  r  r  s    @@r   r  r  0  s3       "Dooa G! Lr   c                    [        U S5      (       a>  U R                  b%  [        U R                  [        5      (       a  [        $ U R                  $ [	        U [
        5      =(       a    [        =(       d    [        nU" U [        5      (       a  [        $ U" U [        5      (       a  [        $ U" U [        5      (       a  [        $ [        U S5      (       a  [        $ [        U S5      (       a  [        $ [        U S5      (       a  [        $ U$ )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__ri   r@   r>   )rh   r%  
issubclassr>   rH   rZ   r   r   )specimenr\  isas      r   duck_type_collectionr)  >  s     x((  ,!!32
 2
 J(((
Xt
$
3
AzC
8T	Xs		
	Xt		x""	5	!	!
	5	!	!r   c           
      ,   [        X5      (       a  U $ [        U[        5      (       aB  [        R                  " SU< SSR	                  S U 5       5      < S[        U 5      < S35      e[        R                  " SU< SU< S[        U 5      < S35      e)	Nz
Argument 'z ' is expected to be one of type z or c              3   ,   #    U  H
  nS U-  v   M     g7f)z'%s'Nr<   )rQ   r  s     r   rS   "assert_arg_type.<locals>.<genexpr>f  s     $AAVaZs   z, got ''z' is expected to be of type 'z', got ')rH   rj   r	   ArgumentErrorrU   rZ   )r   argtyper   s      r   assert_arg_typer0  _  sw    #
gu%%##$A$AA49N 
 ##$s)- r   c           	      0  ^ ^ [         R                  (       a+  [        T S5      (       a  [        T R	                  5       5      $ OK[        T S5      (       a  T R                  5       $ [        T S5      (       a  [        T R	                  5       5      $ [        T S[        T SS5      5      mTc  [        ST -  5      e[        T S5      (       a  U U4S jnU" 5       $ [        T S	5      (       a#  [        U4S
 jT R                  5        5       5      $ [        ST -  5      e)z?Return a (key, value) iterator for almost any dict-like object.rR  	iteritems__getitem__r   NzObject '%r' is not dict-likeiterkeysc               3   T   >#    TR                  5        H  n U T" U 5      4v   M     g 7fr   )r4  )r  dictlikegetters    r   iterator$dictlike_iteritems.<locals>.iterator  s(     ((*6#;&& +s   %(r  c              3   6   >#    U  H  oT" U5      4v   M     g 7fr   r<   )rQ   r  r7  s     r   rS   %dictlike_iteritems.<locals>.<genexpr>  s     B/3&+&/s   )
r   r   rh   r   rR  r2  iterr\   r   r  )r6  r8  r7  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                   2   ^  \ rS rSrSrU 4S jrS rSrU =r$ )classpropertyi  a)  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                 X   > [         [        U ]
  " U/UQ70 UD6  UR                  U l        g r   )superr>  r   r9   )r   r  r   ro  r[   s       r   r   classproperty.__init__  s'    mT+D=3="=||r   c                 $    U R                  U5      $ r   )r  )descr   rC   s      r   r  classproperty.__get__  s    yy~r   )r9   )	r5   r6   r7   r8   r9   r   r  r;   __classcell__r[   s   @r   r>  r>    s    $ r   r>  c                   &    \ rS rSrS rS rS rSrg)hybridpropertyi  c                     Xl         Xl        g r   )r   r*  r   r   s     r   r   hybridproperty.__init__  s    	r   c                 P    Uc  U R                  U5      nU$ U R                  U5      $ r   r*  r   )r   instanceownerclsvals       r   r  hybridproperty.__get__  s*    ]]5)FM99X&&r   c                     Xl         U $ r   r6  rJ  s     r   
classlevelhybridproperty.classlevel      r   rM  N)r5   r6   r7   r8   r   r  rS  r;   r<   r   r   rH  rH    s    'r   rH  c                   *    \ rS rSrSrS rS rS rSrg)hybridmethodi  z/Decorate a function as cls- or instance- level.c                 ,    U=U l         U l        Xl        g r   )r   r   r*  rJ  s     r   r   hybridmethod.__init__  s    $((	DMr   c                     Uc%  U R                   R                  X"R                  5      $ U R                  R                  X5      $ r   )r*  r  r[   r   )r   rN  rO  s      r   r  hybridmethod.__get__  s6    ==((@@99$$X55r   c                     Xl         U $ r   r6  rJ  s     r   rS  hybridmethod.classlevel  rU  r   )r   r*  r   N)	r5   r6   r7   r8   r9   r   r  rS  r;   r<   r   r   rW  rW    s    96r   rW  c                   0    \ rS rSrSS jrS rS rS rSrg)	_symboli  Nc                     [        U[        R                  5      (       d   eUc  [        U5      n[        R                  [        U5      nXl        U(       a  X$l        U$ )zConstruct a new named symbol.)	rH   r   rI   hashr  __new__r_  r   r9   )r   r   r   	canonicalvs        r   rb  _symbol.__new__  sL    $ 3 34444T
IKK+Ir   c                 >    [         U R                  S[        U 5      44$ )Nr   )r   r   r  r#   s    r   
__reduce___symbol.__reduce__  s    		3D	222r   c                     [        U 5      $ r   )rH  r#   s    r   __str___symbol.__str__  s    Dzr   c                      SU R                   -  $ )Nz
symbol(%r))r   r#   s    r   __repr___symbol.__repr__  s    dii''r   r<   NN)	r5   r6   r7   r8   rb  rg  rj  rm  r;   r<   r   r   r_  r_    s    	3(r   r_  r   c                   p    \ rS rSrSr0 r\R                  R                  5       r	SS jr
\ SS j5       rSrg)	r   i  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                     U R                      U R                  R                  U5      nUc  [        XU5      =U R                  U'   nUsS S S 5        $ ! , (       d  f       g = fr   )_locksymbolsr   r_  )rC   r   r   rc  r|   s        r   rb  symbol.__new__  sG    YY++//$'C{*1$Y*GGD!C	 YYs   ;A
A c                     UR                  5        H0  u  pVXL a  Us  $ U(       a  XR                  :X  a  Us  $ X;   d  M.  Us  $    Uc  g[        R                  " SU< SU< 35      e)a5  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': )rR  r   r	   r.  )rC   r   choicesr   resolve_symbol_namesr|   choices          r   parse_user_argumentsymbol.parse_user_argument  sZ    , #==?KCz
%#/

 + ;c JKKr   r<   ro  r4   )r5   r6   r7   r8   r9   rs  r   r!  r"  rr  rb  r)  ry  r;   r<   r   r   r   r     s@    * G!!#E 6; L  Lr   c                 ,    [         U l         [         S-  q g)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)rN  s    r   set_creation_orderr}  "  s      /HqOr   c                 |     U " U0 UD6$ ! [          a'    [        S[        R                  " 5       SS -  5         gf = f)zPexecutes the given function, catches all exceptions and converts to
a warning.

z%s('%s') ignoredr   r   N)rK   r+   r!   r"   )r   r   r@  s      r   warn_exceptionr  /  sA    
7T$V$$ 7#,,.1"5567s   
 .;;c                 Z     [        U 5      U:  a  SU SU -  $ U $ ! [         a    U s $ f = f)Nz%s...r   )r  r   )r-   len_s     r   ellipses_stringr  :  s=    u:U1T]**L s     **c                   8   ^  \ rS rSrSrU 4S jrS rS rSrU =r	$ )_hash_limit_stringiD  a  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                    > X-  SU-  -   n[         [        U ]  X5      n[        SU[        U5      U-  4-  5      Ul        U$ )Nz6 (this warning may be suppressed after %d occurrences)z%s_%d)r@  r  rb  ra  _hash)rC   r-   numr   interpolatedr   r[   s         r   rb  _hash_limit_string.__new__O  sP    DsJ
 '5cH'UD,>,D$EEF
r   c                     U R                   $ r   r  r#   s    r   __hash___hash_limit_string.__hash__W  s    zzr   c                 0    [        U 5      [        U5      :H  $ r   )ra  )r   others     r   __eq___hash_limit_string.__eq__Z  s    DzT%[((r   r  )
r5   r6   r7   r8   r9   rb  r  r  r;   rE  rF  s   @r   r  r  D  s    ) )r   r  c                     U(       a  [        [        R                  " XS95        g[        U [        R                  5        g)zXIssue 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}}S45sCMM*r   c                 `    U(       a  [        U SU5      n [        U [        R                  5        g)zTIssue a warning with a parameterized string, limiting the number
of registrations.


   N)r  r  r	   r  )r  r   s     r   warn_limitedr  k  s#    
  b$/3&r   c                     [         R                  " U5      nUb  [        R                  " SUR                  R                  SS5      5      (       aL  UR                  nUS-  nUb8  [        R                  " SUR                  R                  SS5      5      (       a  ML  Ub  [        R                  " XUS-   S9  g [        R                  " XS-   S9  g ! [         a    Sn NB  Sn NG= f)Nz^(?:sqlalchemy\.|alembic\.)r5   r  r   r   )
stacklevel)
r!   	_getframerV   match	f_globalsr   f_backr  warningsr+   )messagecategoryr  frames       r   r  r  u  s    j) BHH*EOO,?,?
B,O%
 %
 LLE!OJ	 BHH*EOO,?,?
B,O%
 %
 gJNCgq.9+   
 
s   C C$C$c                 "   ^ ^^ T /mU UU4S jnU$ )zJDecorate the given function to be a no-op after it is called exactly
once.c                     > TnT(       a  TR                  5       n U" U 0 UD6$ g !   T(       a  TR                  SU5        e = f)Nr   )r?   insert)r   ro  	strong_fnonce_fnr   onceretry_on_exceptions       r   goonly_once.<locals>.go  sM     	hhjG*r** %KK7+s	   % Ar<   )r   r  r  r  s   `` @r   	only_oncer    s     4D Ir   z%sqlalchemy/([a-z_]+/){0,2}[a-z_]+\.pyzunit(?:2|test2?/)c                 4   Sn[        U 5      S-
  nX4::  a<  UR                  X   5      (       a$  US-  nX4::  a  UR                  X   5      (       a  M$  X4::  a<  UR                  X   5      (       a$  US-  nX4::  a  UR                  X   5      (       a  M$  XU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_suffixre   ends        r   chop_tracebackr    s     E
b'A+C
,>00;;
 ,>00;;
,>0099q ,>0099cAgr   c                 \    SU -  n[        5       R                  5       n[        X5        US   $ )Nz&def set(obj, value):    obj.%s = valuer>   )r  copyr   )attrnamer   r   s      r   
attrsetterr    s*    6AD
(--/COu:r   c                   2   ^  \ rS rSrSrU 4S jrS rSrU =r$ )EnsureKWArgTypei  zQApply translation of functions to accept \**kw arguments if they
don't already.

c                 @  > U R                   nU(       av  U Hp  n[        R                  " XE5      nU(       d  M"  X5   n[        R                  " U5      nUR
                  (       a  MO  U R                  U5      =X5'   n	[        XU	5        Mr     [        [        U ]+  XU5        g r   )ensure_kwargrV   r  r   r   r  
_wrap_w_kwr7  r@  r  r   )rC   clsnamerz   clsdictfn_regr  r   r   r   wrappedr[   s             r   r   EnsureKWArgType.__init__  s    !!HHV)1 B!88<D:::141CCw'2  	os,WWEr   c                 (   ^ U4S jn[        UT5      $ )Nc                     > T" U 6 $ r   r<   )r   ro  r   s     r   wrap(EnsureKWArgType._wrap_w_kw.<locals>.wrap  s    s8Or   r   )r   r   r  s    ` r   r  EnsureKWArgType._wrap_w_kw  s    	 dB''r   r<   )	r5   r6   r7   r8   r9   r   r  r;   rE  rF  s   @r   r  r    s    
F( (r   r  c                    [        US5      (       a  [        X5      $ U nUR                  R                  Ul        [        US5      (       a  UR                  Ul        [        UR
                  S5      (       a8  UR
                  R                  (       a  UR
                  R                  Ul        U$ UR                  (       a  UR                  Ul        U$ )zAugment functools.update_wrapper() to work with objects with
a ``__call__()`` method.

:param fn:
  object with __call__ method

r5   r6   r9   )rh   r   r[   r5   r6   r   r9   )wrapperr   _fs      r   wrap_callabler    s     r:g**ll++2|$$MMBM2;;	**r{{/B/B,,BJ 	 ZZBJ	r   c                    SU ;  a  U R                  S5      $ Sn/ /nSn[        U 5      nX4:  a  X   nUS:X  a9  US:X  a-  X4S-
  :  a%  XS-      S:X  a  US   R                  S5        US-  nO8US-  nO2US:X  a  US:X  a  UR                  / 5        OUS   R                  U5        US-  nX4:  a  M  U Vs/ s H  nSR                  U5      PM     sn$ s  snf )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  ri   rU   )r-   ri  r  idxlvcharr   s          r   quoted_token_parserr    s    $ %{{3 ETF
C	UB
(z3;zcFlu1W~/Dr
!!#&q
S[UaZMM"2Jd#q ( )//uBGGEN///s   4Cc                 D   ^ ^ [         R                  " T 5      m U U4S jnU$ )Nc                    > U R                   S L=(       a    U R                   =(       d    SnU(       a  [        UT Vs0 s H  o"T_M     sn5      nXl         U $ s  snf )Nr  )r9   inject_param_text)r   r   paramparamsr  s      r   r   $add_parameter_text.<locals>.decorate-  sO    jj$39r#C6)J6%+6)JKC
	 *Ks   A
)r   rN  )r  r  r   s   `` r   add_parameter_textr  *  s    !!&)F Or   c                     U R                  SS5      n[        U5      S:X  a  U $ Uu  p#UR                  S5      (       d  US-   [        R                  " U5      -   $ [        R                  " U 5      $ )Nr)   r   r(   )r   r  r  textwrapdedent)r  
split_text	firstline	remainings       r   _dedent_docstringr  7  sd    D!$J
:!)	$$4(//)"<<<t$$r   c                    [        U =(       d    S5      n U R                  S5      n[        U5      S:X  a  UR                  S5        [        R
                  " U5      R                  S5      nUS   (       a  UR                  SS5        [        U5       VVs/ s H  u  pVUR                  5       (       a  M  UPM      nnnUR                  SS5        U[        U[        U5      S-
  5         nUSU U-   X8S  -   nSR                  U5      $ s  snnf )Nr  r)   r   r   )r  r   r  ri   r  r  r  rP  r  minrU   )	doctext
injecttextposlinesinjectlinesr  lineblanks
inject_poss	            r   r   r   C  s    2.GMM$E
5zQR//*-33D9K1~1b!#,U#3H#3ic4::<c#3FH
MM!QCVq12J!J+-k0BBE99U Is   D4Dz(\s+):param (.+?):c                 @   [         R                  " U R                  5       5      n/ nS nU(       Ga^  UR                  5       n[        R                  U5      nUc  U(       a  UR                  S5      R                  S5      nXq;   al  S[        UR                  S5      5      -  S-   nU(       a>  [        R
                  " SUS   5      n	U	(       a  S[        U	R                  S5      5      -  nXU   -   nOU(       a  UR                  SUS/5        S nOdUR                  5       (       d  UR                  XTS/5        S nO9UR                  S5      (       a#  UR                  XRR                  5       /5        GMK  UR                  U5        U(       a  GM^  SR                  U5      $ )	Nr   *r(   r   z(\s+)\Sr   r)   z::)collectionsdeque
splitlinespopleft
_param_regr  r   lstripr  rV   rA   rstripr  ri   rU   )
r  inject_paramsdoclinesr  	to_injectr  r   r  indentm2s
             r   r  r  X  sX     !3!3!56HE I
!T"
))#.) 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                 4   [        U 5      S:X  a  g[        U 5      S:*  nU(       a  U SS O
U SS U SS -   n U  Vs/ s H  n[        U5      S:  a  SUSS -  OUPM     nnU(       a  SR                  U5      $ SR                  USS 5      < S	US   < 3$ s  snf )
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..rL  z, ..., )r  rU   )r   flagr   ress       r   repr_tuple_namesr    s     5zQu:?DE!AJE!AJrs$;EFK
LedTR6D"IT9eC
Lyy~ $		#a( 3SW==	 Ms   #Bc                  J     SSK Jn   SSK Jn  SSK Jn  g! [         a     gf = f)Nr   )cimmutabledict)cprocessors)cresultproxyTF)r   r  r  r  r   )r  r  r  s      r   has_compiled_extr     s%    -*+ s    
""r   )FF)T)r<   r<   r<   )r<   Nr<   )NNz
self.proxyN)NNN)TN)   )Nr   )ar9   r  	functoolsr   r   r   rt   r  rV   r!   r  r   r  r  r   r   r	   r   r  r   rF   rM   rX   rb   rm   r}   r   r   r   r   r   r   r   r   r   r  r   r!  r>  rA  rE  r`  rb  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r)  r0  r  propertyr>  rH  rW  r  r_  r5   r   r|  r}  r  r  	text_typer  r+   r  r  r  compile_SQLA_RE_UNITTEST_REr  rZ   NoneTyper  r  r  r  r  r  r   r  r  r  r   r<   r   r   <module>r	     sw  
  $     	 
      .;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
+'::, ::>?zz./ '38 , :(d (40)0X
	%$ ZZ-.
(V>r   