
    ؄_X                        d 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dZdZ G d de          Zd ZdZdZd Zd[dZd\dZd\dZ d Z!d Z"d]d Z# G d! d"e          Z$d# Z%d$ Z&	 	 	 	 d^d&Z'd' Z(d_d(Z) G d) d*e          Z*d+ Z+ G d, d-e          Z, G d. d/e          Z-d`d0Z.d1 Z/d2 Z0d3 Z1dad4Z2d5 Z3d6 Z4dZd7Z5d8 Z6d9 Z7 G d: d;e8          Z9 G d< d=e          Z: G d> d?e          Z; G d@ dAe<          Z=dBe=_>         G dC dBe          Z?da@dD ZAdE ZBdbdGZC G dH dIejD                  ZEdJ ZFdK ZGdL ZH ejI        dM          ZJ ejI        dN          ZKeKeJfdOZL eMd          ZNdP ZO G dQ dReM          ZPdS ZQdT ZRdU ZSdV ZTdW ZUdX ZVdY ZWdS )czRoutines to help with the creation, loading and introspection of
modules, classes, hierarchies, attributes, functions, and methods.

    update_wrapperN   )_collections)compat   )excc                     t           j        r|                     d          } t          j                    }|                    |            |                                S )Nzutf-8)r   py3kencodehashlibmd5update	hexdigest)xms     `/var/www/book.euthymeo.com/html/venv/lib/python3.11/site-packages/sqlalchemy/util/langhelpers.pymd5_hexr      sE    { HHWAHHQKKK;;==    c                   *    e Zd ZdZdZddZd Zd ZdS )	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_infoFc                     || _         d S N)r   )selfr   s     r   __init__zsafe_reraise.__init__8   s    "r   c                 6    t          j                    | _        d S r   )sysexc_infor   r   s    r   	__enter__zsafe_reraise.__enter__;   s    r   c                 B   |3| j         \  }}}d | _         | j        st          j        ||           d S d S t          j        s@| j         r9| j         d         r,t          d| j         d         d| j         d         d           d | _         t          j        ||           d S )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> dnQ6G   (,~a'8'8'8$.:K:K:KM  
 "DNM%	::::::r   NF)__name__
__module____qualname____doc__	__slots__r   r"   r/    r   r   r   r   $   sW         " +I# # # #( ( (; ; ; ; ;r   r   c                 p    d                     d t          j        d| j                  D                       S )Nr%   c              3   >   K   | ]}|                                 V  d S r   )lower).0ns     r   	<genexpr>z(clsname_as_plain_name.<locals>.<genexpr>V   s;        		     r   z([A-Z][a-z]+))joinrefindallr1   )clss    r   clsname_as_plain_namerA   U   sC    88  :&6EE     r   c                     g }| j         | j        | j        fD ];}t          |d          r|                                }|                    |           <t          |          S )zrdecode a slice object as sent to __getitem__.

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

    	__index__)startstopstephasattrrC   appendtuple)slcretr   s      r   decode_slicerL   [   sa     CY#(*  1k"" 	A

1::r   c           
   '     K   t          |           } |D ]qt          j        ft          j        fdt          d                              }|D ]!}|| vr|                     |           |V   n"t          dz            rd S )Nc                 (    t          |           z   S r   )str)ibases    r   <lambda>z!_unique_symbols.<locals>.<lambda>n   s    D3q66M r   i  z&exhausted namespace for symbol base %s)set	itertoolschainr   itertools_imaprangeadd	NameError)usedbasespoolsymrQ   s       @r   _unique_symbolsr^   i   s      t99D M MG!"9"9"9"95;;GG
 
  	M 	MC$			 
 DtKLLL M Mr   c              #   L   K   |r|| dz   z  } | |          V  ||z  }|dS dS )z6Call the given function given each nonzero bit from n.r   Nr6   )fnr;   bs      r   map_bitsrb   y   sW        !aLbee	Q      r   c                 .      fd}t          |           S )z'A signature-matching decorator factory.c                 4   t          j        |           s#t          j        |           st          d          t	          j        |           }t          |d                   |dd         z   | j        fz   }t          |dd          \  }}t          ||          }|
                    t          |d	                     | j        |d
<   d|z  }t          |||| i| j                  }t          | d|           j        |_        | |_        t!          ||           S )Nznot a decoratable functionr   r      targetr`   )rf   r`   FgroupednamezDdef %(name)s(%(args)s):
    return %(target)s(%(fn)s, %(apply_kw)s)
im_func)inspect
isfunctionismethod	Exceptionr   inspect_getfullargspecrI   r1   r^   dictr   format_argspec_plus_exec_code_in_envgetattr__defaults____wrapped__r   )	r`   specnames	targ_namefn_namemetadatacode	decoratedrf   s	           r   decoratezdecorator.<locals>.decorate   s(   !"%% 	:g.>r.B.B 	:8999,R00d1gac*bk^;,UHdCC	7yW555+D%@@@AAA; 	 	 &9fgr2BK
 
	 ")Y!;!;!H	 "	i,,,r   r   )rf   r}   s   ` r   	decoratorr~      s.    - - - - -2 (F+++r   c                 2    t          | |           ||         S r   )exec)r{   envry   s      r   rr   rr      s    sOOOw<r   c                    t          | t                    r| j        }| }d| j        d|d}n	| x}}d|z  }|                    d          d         }t          j        |          }|d         d= t          |d	          }||d
<   d|z  }	|t          d}
t          |	|
           |
|         }t          |d          rD|j        \  }}|j        }|| j        d| j        }t          |d|d|dd          }||_        n|j        |_        d|                    dd          d         z   |_        |j        t           j        vrt%          d|j        d          t
          j        st          |d          r0||j        _        t          |j        d          s||f|j        _        n ||_        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:`.zX` 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   Frg   ri   z5def %(name)s(%(args)s):
    return cls(%(apply_kw)s)
)r@   symbol
_linked_toNzE.. container:: inherited_member

    Inherited from :func:`sqlalchemyz&`; this constructor creates a :class:`z` objectr   
sqlalchemyzpublic_factory location z is not in sys.modules__func__)
isinstancetyper   r1   splitr   ro   rq   r   r   rG   r   r4   r2   inject_docstring_textrsplitr   modulesImportErrorpy2kr   )rf   locationclass_locationr`   	callable_doclocation_namerv   rz   r{   r   r|   	linked_tolinked_to_locationlinked_to_docs                  r   public_factoryr      s=    &$ 
_		 	* 	  Y.089 	
 NN3''+M(,,DQ
"4777H$HV	 		 	 v
.
.CsOOOM"Ir<   '(*%	%!)!(.(9(9(96??KN-M "!!>>>3 
 
 *	J	'(//#q*A*A!*DDI3;..k###&
 
 	
 { 2gb*-- 2!r{L11 	;&/%:BK"
r<(( 	2&1BMr   c                   (    e Zd ZddZd Zd Zd ZdS )PluginLoaderNc                 0    || _         i | _        || _        d S r   )groupimplsauto_fn)r   r   r   s      r   r   zPluginLoader.__init__   s    

r   c                 8    | j                                          d S r   )r   clearr!   s    r   r   zPluginLoader.clear   s    
r   c                    || j         v r | j         |                     S | j        r+|                     |          }|r|| j         |<    |            S 	 dd l}|                    | j        |          D ]&}|j        | j         |<   |                                c S n# t          $ r Y nw xY wt          j        d| j        d|          )Nr   zCan't load plugin: :)	r   r   pkg_resourcesiter_entry_pointsr   loadr   r	   NoSuchModuleError)r   ri   loaderr   impls        r   r   zPluginLoader.load   s   4:#4:d#%%%< 	 \\$''F  #)
4 vxx	#     &77
DII # ##'9
4 yy{{"""#  	 	 	D	 ##*.***dd;
 
 	
s   B 
B&%B&c                 *    fd}|| j         |<   d S )Nc                      t          j                  }                     d          dd          D ]}t          | |          } t          |           S )Nr   r   )r   import_r   rs   )modtoken
modulepathobjnames     r   r   z#PluginLoader.register.<locals>.load  sY    .,,C#))#..qrr2 * *c5))3(((r   )r   )r   ri   r   r   r   s     `` r   registerzPluginLoader.register  s6    	) 	) 	) 	) 	) 	)  
4r   r   )r1   r2   r3   r   r   r   r   r6   r   r   r   r      sU           
  
 
 
.         r   r   c                     	 t           j        }| j        }|j        }t	          |j        d |                   t          |j        |z            fS # t          $ r4 t          j
        |           }|d         t          |d                   fcY S w xY w)Nr   r   )rk   CO_VARKEYWORDS__code__co_argcountlistco_varnamesboolco_flagsAttributeErrorr   ro   )r`   co_varkeywordsconargsrv   s        r   _inspect_func_argsr     s    
 / ['((~-..
 	
  & & &
 ,R00AwT!W%%%%&s   A ;BBc                    |du }|rt                      }| j                            dd          }|o8t          |t          j                  ot          |j        t          j                  }|r-t          |          \  }}|	                    |           |s|sdS |r|r| j
        D ]}t          ||           n|                    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   )rS   __dict__getr   typesFunctionTyper   CodeTyper   r   	__bases__get_cls_kwargsdiscard)r@   _settoplevelctrhas_initrw   has_kwcs           r   r   r   .  s     t|H uu
,

:u
-
-C 	 	5sE.//	5s|U^44   *3//vE 	h 	4 v  	 	Aa&&. / 	LLKr   c                 6    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   ro   funcs    r   get_func_kwargsr   Y  s     (..q11r   Fc           	         t          j        |           rt          d| z            t          j        |           rq|r[|rYt	          j        |           }t	          j        |j        dd         |j        |j	        |j
        |j        |j        |j                  S t	          j        |           S t          j        |           r|rg|s| j        r^t	          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          rAt          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)rk   	isbuiltin	TypeErrorrl   r   ro   FullArgSpecargsvarargsvarkwdefaults
kwonlyargskwonlydefaultsannotationsrm   __self__r   isclassget_callable_argspecr   rG   r   )r`   r   r   rv   s       r   r   r   d  s     *;3b8999		B		 (; 	5 	5044D%	!""
#    0444		"		 ; 	> 	>BK 	>0==D%	!""
#    0===			 ;#K4
 
 
 	
 
Z	 	  ;,R[999	Z	 	  ;BK(( 	?'WEEEE82=>>>4r9:::r   Tc                    t          j        |           rt          j        |           }n| }t          j        | }|d         r|d         d         }n|d         rd|d         z  }nd}t          j        |d         |d         |d         d|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	 
          }	|rt          ||||	          S t          |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.

    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   z%s[0]Nr      re   r6   c                     d| z   S )N=r6   )r   s    r   rR   z%format_argspec_plus.<locals>.<lambda>  s
    cAg r   )formatvalue)r   self_arg	apply_posapply_kwr   )r   callablero   inspect_formatargspeclenrp   )
r`   rh   rv   r   r   r   num_defaults	name_argsdefaulted_valsr   s
             r   rq   rq     s   @ r ,R00'.DAw 71:	a T!W$,Qa$q'4a I LAw %DG$Aw %DG$Q$q'!I "1|#3#5#56+QQ%%  H  
	
 
 
 	
 ad"oad^	
 
 
 	
r   c                     | t           j        u r|rdpd}n(	 t          | |          S # t          $ r	 |rdpd}Y nw xY wt	          d|||          S )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   rg   z(self, *args, **kwargs)zself, *args, **kwargs)r   r   r   r   )objectr   rq   r   rp   )methodrh   r   s      r   format_argspec_initr     s       #8-v	&vw???? 	 	 	 .-+* DD	 ddTJJJJs   ( ;;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   ro   r   r   r   )r   s    r   getargspec_initr     sn    6,V444 6 6 6V_$$HdD$////Hfh5555	6s    AA Ac                 V    t          | t          j                  r| j        s| j        S | S )zSAdjust the incoming callable such that a 'self' argument is not
    required.

    )r   r   
MethodTyper   r   )func_or_clss    r   unbound_method_to_callabler     s2     +u/00 9M ##r   r6   c           	      V    | g}nt          j        |          }t                      g }t          j                    }d}t	          |          D ]\  }}	 t          j        |j                  }	|	j        rt          |	j                  pd}
|dk    rW|	j
        r|	j
        }|
r$|                    |	j        d|
                     nR|                    |	j        dd                    n/|                    fd|	j        d|
          D                        |
r@|                    d t          |	j        |
 d         |	j                  D                        # t          $ r Y w xY wg }|                     fd|D                        |=t!           |          r-|                    d t#           |          D                        |                                D ]P\  }}||v r
	 t#           |          }|ur ||k    r|                    |d|           A# t(          $ r Y Mw xY w|rN|D ]K\  }}	 t#           |          }|ur ||k    r|                    |d|           <# t(          $ r Y Hw xY w j        j        d	d
                    |          dS )z}Produce a __repr__() based on direct association of the __init__()
    specification vs. same-named attributes present.

    Nr   r   c                     g | ]}|fS r6   r6   )r:   argmissings     r   
<listcomp>z generic_repr.<locals>.<listcomp>B  s    IIIc7^IIIr   c                     g | ]	\  }}||f
S r6   r6   )r:   r   defaults      r   r   z generic_repr.<locals>.<listcomp>G  s0       (C g  r   c              3   T   K   | ]"}t          t          |d                     V  #d S r   )reprrs   )r:   r   objs     r   r<   zgeneric_repr.<locals>.<genexpr>P  s7      DDC$wsC..//DDDDDDr   c                 ,    g | ]}t          |          S r6   r  )r:   vals     r   r   z generic_repr.<locals>.<listcomp>S  s    @@@StCyy@@@r   r   (, ))r   to_listr   OrderedDict	enumerater   ro   r   r   r   r   extendr   r   zipr   rG   rs   itemsrH   rn   	__class__r1   r=   )r  additional_kw
to_inspect
omit_kwargpos_argskw_argsvargsrP   insprv   default_lenoutputr   defvalr  r   s   `              @r   generic_reprr  #  s[   
 U

!)*55
hhGH&((GEZ((  4	0??D ->C,>,>C!KAvv< ) LE 3OODIan$=>>>>OODIabbM2222IIIItyK</HIII     ,/ I{lmm4dm- -    #  	 	 	H	2 F
MMDDDD8DDDDDDWS%00@@GC,?,?@@@AAA}}  V*	#sG,,C'!!cVmmcc2333 	 	 	D	  ( 	 	KCc300g%%#--MMSSS##"6777    }---tyy/@/@/@/@AAs6   E
E,+E,05H&&
H32H3 5I66
JJc                   0    e Zd ZdZdZd Zd Zd	dZd ZdS )
portable_instancemethodz_Turn an instancemethod into a (parent, name) pair
    to produce a serializable callable.

    )rf   ri   r   __weakref__c                 ,    | j         | j        | j        dS )Nrf   ri   r   r"  r!   s    r   __getstate__z$portable_instancemethod.__getstate__s  s     kIk
 
 	
r   c                 p    |d         | _         |d         | _        |                    dd          | _        d S )Nrf   ri   r   r6   )rf   ri   r   r   )r   states     r   __setstate__z$portable_instancemethod.__setstate__z  s1    Ho&M	ii"--r   r6   c                 D    |j         | _        |j        | _        || _        d S r   )r   rf   r1   ri   r   )r   methr   s      r   r   z portable_instancemethod.__init__  s    mM	r   c                 v    |                     | j                    t          | j        | j                  |i |S r   )r   r   rs   rf   ri   )r   r   kws      r   r   z portable_instancemethod.__call__  s9    
		$+.wt{DI..:r:::r   Nr6   )	r1   r2   r3   r4   r5   r#  r&  r   r   r6   r   r   r  r  k  sf         
 :I
 
 
. . .
   
; ; ; ; ;r   r  c                 
   t           j        r(t          | t          j                  rt                      S | ht          | j                  }|r&|                                }t           j        r/t          |t          j                  r>fd|j        D             }nfd|j        D             }|D ],}|	                    |           
                    |           -t           j        r|j        dk    st          |d          sn|j        dk    st          |d          sوfd|                                D             D ],}|	                    |           
                    |           -|&t                    S )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   X   K   | ]$}|vt          |t          j                   |V  %d S r   )r   r   	ClassTyper:   _hiers     r   r<   z"class_hierarchy.<locals>.<genexpr>  sE        D==Au)G)G=  === r   c              3   $   K   | ]
}|v|V  d S r   r6   r/  s     r   r<   z"class_hierarchy.<locals>.<genexpr>  s'      ==1q}}Q}}}}==r   builtins__subclasses____builtin__c                     g | ]}|v|	S r6   r6   r/  s     r   r   z#class_hierarchy.<locals>.<listcomp>  s    AAA1D==!===r   )r   r   r   r   r.  r   __mro__popr   rH   rX   r   r2   rG   r4  )r@   processr   r[   ra   sr1  s         @r   class_hierarchyr;    s    { c5?++ 	66M5D3;G
 KKMM; 		>!U_--      EE >======E 	 	ANN1HHQKKKK; 	|z))<L1M1M) * |},,G#5 5, AAAAQ--//AAA 	 	ANN1HHQKKKK9  : ::r   c              #   ~   K   t          |           }|D ](}| j        D ]}||j        v r||j        |         fV   n)dS )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)dirr7  r   )r@   keyskeyr   s       r   iterate_attributesr@    sl       s88D   	 	Aaj  AJsO,,,, ! r   
self.proxyc                     |r|}n d fdt          |          D             }|D ]}	 t          ||          }t          |d          s%t          |d|          }n# t          $ r Y Cw xY w	 t	          j        |          }	t	          j        |	d                   }
t	          j        |	d         dd                   }n# t          $ r d}
d	}Y nw xY wd
t                      z  }|dur||ipi }t	          j	        ||           	 |j
        ||         _
        n# t          $ r Y nw xY wt           |||                    dS )z9Automates delegation of __specials__ for a proxying type.N)r5   __del____getattribute____metaclass__r#  r&  c                     g | ]B}|                     d           r+|                    d           rt          |          s|v@|CS )__)
startswithendswithrG   )r:   r   into_clsskips     r   r   z0monkeypatch_proxied_specials.<locals>.<listcomp>  sl     	
 	
 	
T""		

 JJt$$	
  !,,	
 TMM  "MMr   r   rj   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=  rs   rG   r   r   ro   r   r   localsexec_rt   setattr)rJ  from_clsrK  onlyri   from_instancedundersr   r`   rv   fn_argsd_argspyr   s   ` `           r   monkeypatch_proxied_specialsrV    s     
<D	
 	
 	
 	
 	
]]	
 	
 	
  / /	6**B2z** Y++BB 	 	 	H		%044D247;;G1$q'!""+>>FF 	% 	% 	%+G$FFF	%
35;XX> 	
 4'AT=,AGRR	')CK$$ 	 	 	D	&#f+....7/ /s<    A!A!!
A.-A.2ACCCD
D('D(c                 F    t          | d|           t          |d|          u S )z;Return True if the two methods are the same implementation.r   )rs   )meth1meth2s     r   methods_equivalentrZ    s0     5*e,,z51 1  r   c           	      `   |s|st          d          t          |t                    rt          | |          r| S t          |pd t	          |          D                       }t          t	          |                     }t
          j        }t          |t                    r|}n,|st                      }t
          j        }nt          |          } ||                    |          |          r| S t          | t                    s<|t
          j        u rdpd}t          | d|dd
                    |                     G d d	t                    }|rd
|j        z   |_        t                      }	t          |           D ]w\  }
}|
|vrt          d|
z            t          j        |          st          |
d|d          t!          ||
t#          |                     |	                    |
           x ||	|          r|S t          dd
                    ||	z
            z            )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 requiredc                 <    g | ]}|                     d           |S )r0  )rH  )r:   r   s     r   r   z as_interface.<locals>.<listcomp>:  s)    MMMa1<<;L;LMMMMr   zany ofzall ofz does not implement z: r
  c                       e Zd ZdZdS )(as_interface.<locals>.AnonymousInterfacezA callable-holding shell.N)r1   r2   r3   r4   r6   r   r   AnonymousInterfacer^  Q  s        ''''r   r_  	Anonymousz%r: unknown in this interfacer   z is not callablez,dictionary does not contain required keys %s)r   r   r   rS   r=  operatorgegtintersectionrp   r=   r   r1   dictlike_iteritemsr   r   rN  staticmethodrX   )r  r@   methodsrequired	interfaceimplementedcomplies	qualifierr_  foundr   r   s               r   as_interfacern    s~   B  Nw NLMMM#t C!5!5 
GMMM3s88MMMNNIc#hh--K{H(D!! ! !55;x==x((33X>> 
 c4   
+8DH	ssIIItyy3335
 
 	

( ( ( ( (V ( ( (  A&1CL&@#EEE*3//  "";fDEEEt$$ 	FvvvtttDEEE"FL,>,>???		&xx   "!!
6
))Hu$
%
%	&  r   c                   <    e Zd ZdZddZd Zd Zed             ZdS )memoized_propertyz2A read-only @property that is only evaluated once.Nc                 H    || _         |p|j        | _        |j        | _        d S r   )fgetr4   r1   )r   rr  r   s      r   r   zmemoized_property.__init__l  s$    	*dlr   c                 V    || S |                      |          x|j        | j        <   }|S r   )rr  r   r1   )r   r  r@   results       r   __get__zmemoized_property.__get__q  s.    ;K/3yy~~=T]#fr   c                 F    t                               || j                   d S r   )rp  resetr1   )r   r  s     r   _resetzmemoized_property._resetw  s     T]33333r   c                 <    |j                             |d            d S r   )r   r8  )r@   r  ri   s      r   rw  zmemoized_property.resetz  s     t$$$$$r   r   )	r1   r2   r3   r4   r   ru  rx  classmethodrw  r6   r   r   rp  rp  i  sg        <<& & & &
  4 4 4 % % [% % %r   rp  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                 z     | g|R i |fd}j         |_         j        |_        || j        j         <   S )Nc                      S r   r6   ar*  rt  s     r   memoz6memoized_instancemethod.<locals>.oneshot.<locals>.memo  s    Mr   )r1   r4   r   )r   r   r*  r  rt  r`   s       @r   oneshotz(memoized_instancemethod.<locals>.oneshot  sc    D&4&&&2&&	 	 	 	 	 z%)bk"r   r   )r`   r  s   ` r   memoized_instancemethodr    s.    	 	 	 	 	 '2&&&r   c                   ,    e Zd ZdZddZd Zd Zd ZdS )	!group_expirable_memoized_propertyz?A family of @memoized_properties that can be expired in tandem.r6   c                 P    g | _         |r| j                             |           d S d S r   )
attributesr  )r   r  s     r   r   z*group_expirable_memoized_property.__init__  s7     	/O"":.....	/ 	/r   c                 T    |j         }| j        D ]}|                    |d           dS )z.Expire all memoized properties for *instance*.N)r   r  r8  )r   instancestash	attributes       r   expire_instancez1group_expirable_memoized_property.expire_instance  s<    ! 	' 	'IIIi&&&&	' 	'r   c                 ^    | j                             |j                   t          |          S r   )r  rH   r1   rp  r   r`   s     r   r   z*group_expirable_memoized_property.__call__  s(    r{+++ $$$r   c                 ^    | j                             |j                   t          |          S r   )r  rH   r1   r  r  s     r   r   z(group_expirable_memoized_property.method  s(    r{+++&r***r   Nr+  )r1   r2   r3   r4   r   r  r   r   r6   r   r   r  r    s[        II/ / / /
' ' '% % %+ + + + +r   r  c                   "    e Zd ZdZdZd Zd ZdS )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   r?  s     r   _fallback_getattrzMemoizedSlots._fallback_getattr  s    S!!!r   c                 r                         d          rt                    t           dz            r. t           dz                        }t	           |           |S t           dz            r(t           dz             fd}j        |_        |S                                S )N	_memoizedz_memoized_attr_%sz_memoized_method_%sc                  v     | 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   rN  )r   r*  r  rt  r`   r?  r   s      @r   r  z*MemoizedSlots.__getattr__.<locals>.oneshot  sY    TR" " " " " !#!zc4(((r   )rH  r   rG   rs   rN  r4   r  )r   r?  r*   r  r`   s   ``  @r   __getattr__zMemoizedSlots.__getattr__  s    >>+&& 	/ %%%T.455 	/<GD"5";<<>>ED#u%%%LT03677 	/4s:;;B	 	 	 	 	 	 	 !jGON))#...r   N)r1   r2   r3   r4   r5   r  r  r6   r   r   r  r    sC          I" " "/ / / / /r   r  c                       fd}|S )Nc                                         d          }t          j        d                    |dd                   t	                      t                      |d         g          }t          ||d                   }t          || j        |            r/t          |d          r|j
                            | j                   | S )Nr   r   r   __all__)r   r   r   r=   globalsrL  rs   rN  r1   rG   r  rH   )r  tokensr   
add_to_all
modulenames      r   r}   z dependency_for.<locals>.decorate  s    !!#&&nHHVAbD\""GIIvxx&*
 
 c6":&&S\3''' 	-'#y11 	-Ks|,,,
r   r6   )r  r  r}   s   `` r   dependency_forr    s)    	 	 	 	 	 	 Or   c                     t          | t          j                  rD|                                                                 } | dv rdS | dv rdS t          d| z            t          |           S )N)trueyesonyt1T)falsenooffr;   f0FzString is not true/false: %r)r   r   string_typesstripr9   
ValueErrorr   )r  s    r   asboolr    ss    #v*++ Ciikk!!66649995;cABBB99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  )r  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 rnt          |t                    rt          | |         |          sG| |         =|t          u r|rt          | |                   ||<   dS  || |                   ||<   dS dS dS dS )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)r   r   r   r  )r*  r?  r)   
flexi_booldests        r   coerce_kw_typer    s     | 	r		E4(( 	0:2c7E0J0J 	sGD==Z=r#wDIIIbgDIII 		 		r   c                      t          |          }|                     fd|                    |          D                         ||i |S )zInstantiate cls using the __dict__ of obj as constructor arguments.

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

    c              3   H   K   | ]}|j         v |j         |         fV  d S r   )r   )r:   kr  s     r   r<   z#constructor_copy.<locals>.<genexpr>#  sC        !"a3<>O>OCLO>O>O>O>O r   )r   r   
difference)r  r@   r   r*  rw   s   `    r   constructor_copyr    ss     3EII    &+&6&6r&:&:      3r   c                  z    t           j                                        t          j        d          fd} | S )z%Return a threadsafe counter function.r   c                                                        	 t                                                      S #                                  w xY wr   )acquirenextrelease)counterlocks   r   _nextzcounter.<locals>._next0  s?    	==LLNNNNDLLNNNNs	   : A)r   	threadingLockrT   count)r  r  r  s    @@r   r  r  )  sN       ""Doa  G      Lr   c                    t          | d          r/| j        !t          | j        t                    rt          S | j        S t	          | t
                    rt          p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__NrH   rX   rS   )rG   r  
issubclassrS   r   r   r   rp   )specimenr  isas      r   duck_type_collectionr  :  s     x(( ) ,!32
 2
, J((
Xt
$
$
3
AzC
s8T 	Xs		 
	Xt		 x"" 	5	!	! 
	5	!	! r   c           
      6   t          | |          r| S t          |t                    rHt          j        d|dd                    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  V  
dS )z'%s'Nr6   )r:   r  s     r   r<   z"assert_arg_type.<locals>.<genexpr>b  s&      $A$AAVaZ$A$A$A$A$A$Ar   z, got ''z' is expected to be of type 'z', got ')r   rI   r	   ArgumentErrorr=   r   )r   argtyperi   s      r   assert_arg_typer  [  s    #w 
gu%% 		##44$A$A$A$A$AAAAA49999N  
 ##44$s))))-  r   c           	      r    t           j        r2t           d          r!t                                                     S nUt           d          r                                 S t           d          r!t                                                     S t           dt           dd                    t          d z            t           d          r fd} |            S t           d	          r-t          fd
 	                                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   X   K                                    D ]} |  |           fV  d S r   )r  )r?  dictlikegetters    r   iteratorz$dictlike_iteritems.<locals>.iterator}  sH      ((** ' '66#;;&&&&&' 'r   r>  c              3   2   K   | ]}| |          fV  d S r   r6   )r:   r?  r  s     r   r<   z%dictlike_iteritems.<locals>.<genexpr>  s0      BB3S&&++&BBBBBBr   )
r   r   rG   r   r  r  iterrs   r   r>  )r  r  r  s   ` @r   re  re  k  sV    { *8W%% 	*(()))	* 8[)) 	*%%'''Xw'' 	*(()))X}ght.L.LMMF~6ABBBx$$ 
C	' 	' 	' 	' 	' 	' xzz	6	"	" CBBBB(--//BBBBBB6AB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                 h     t          t          |           j        |g|R i | |j        | _        d S r   )superr  r   r4   )r   rr  r   r*  r  s       r   r   zclassproperty.__init__  s=    +mT""+D=3==="===|r   c                 ,    |                      |          S r   )rr  )descr   r@   s      r   ru  zclassproperty.__get__  s    yy~~r   )r1   r2   r3   r4   r   ru  __classcell__r  s   @r   r  r    sQ         $ $ $ $ $      r   r  c                       e Zd Zd Zd ZdS )hybridpropertyc                     || _         d S r   r   r   r   s     r   r   zhybridproperty.__init__      			r   c                     |(|                      |          }| j         j        |_        |S |                      |          S r   )r   r4   )r   r  ownerclsvals       r   ru  zhybridproperty.__get__  s<    YYu%%F!Y.FNM99X&&&r   N)r1   r2   r3   r   ru  r6   r   r   r  r    s2          ' ' ' ' 'r   r  c                       e Zd ZdZd Zd ZdS )hybridmethodz/Decorate a function as cls- or instance- level.c                     || _         d S r   r   r  s     r   r   zhybridmethod.__init__  r  r   c                 |    | | j                             ||j                  S | j                             ||          S r   )r   ru  r  )r   r  r  s      r   ru  zhybridmethod.__get__  s:    9$$UEO<<<9$$Xu555r   N)r1   r2   r3   r4   r   ru  r6   r   r   r  r    s8        99  6 6 6 6 6r   r  c                   (    e Zd ZddZd Zd Zd ZdS )_symbolNc                     t          |t          j                  sJ |t          |          }t                              t          |          }||_        |r||_        |S )zConstruct a new named symbol.)	r   r   r  hashr  __new__r  ri   r4   )r   ri   r   	canonicalvs        r   r  z_symbol.__new__  sZ    $ 344444T

IKK++ 	AIr   c                 >    t           | j        dt          |           ffS )Nr   )r   ri   r  r!   s    r   
__reduce__z_symbol.__reduce__  s    	3D		222r   c                      t          |           S r   r  r!   s    r   __str__z_symbol.__str__  s    Dzzr   c                     d| j         z  S )Nz
symbol(%r))ri   r!   s    r   __repr__z_symbol.__repr__  s    di''r   NN)r1   r2   r3   r  r  r   r  r6   r   r   r  r    sU        	 	 	 	3 3 3  ( ( ( ( (r   r  r   c                   j    e Zd ZdZi Zej                                        ZddZ	e
	 dd            ZdS )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                                          	 | j                            |          }|t	          |||          x| j        |<   }|t
          j                                          S # t
          j                                          w xY wr   )_lockr  symbolsr   r  r   r  )r@   ri   r   r  r]   s        r   r  zsymbol.__new__  s    		#+//$''C{*1$Y*G*GGD!CL  """"FL  """"s   8A2 2 BFc                     |                                 D ]&\  }}||u r|c S |r||j        k    r|c S ||v r|c S '|dS 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  ri   r	   r  )r@   r   choicesri   resolve_symbol_namesr]   choices          r   parse_user_argumentzsymbol.parse_user_argument  s    , #==?? 	 	KCczz


% #//





  ;4cc JKKKr   r  r0   )r1   r2   r3   r4   r  r   r  r  r  r  rz  r  r6   r   r   r   r     sv         * G!!##E# # # # 6; L  L  L [ L  L  Lr   c                 2    t           | _         t           dz  a dS )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OOOr   c                     	  | |i |S # t           $ r/ t          dt          j                    dd         z             Y dS w xY w)zXexecutes the given function, catches all exceptions and converts to
    a warning.

    z%s('%s') ignoredr   r   N)rn   r(   r   r    )r   r   r   s      r   warn_exceptionr  %  sc    
7tT$V$$$ 7 7 7#,..1"556666667s   
 5AA   c                 l    	 t          |           |k    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_stringr  0  sT    u::U1T6]**L   s   $ $ 33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  r  r  r  _hash)r@   r*   numr   interpolatedr   r  s         r   r  z_hash_limit_string.__new__E  sf    DsJ
 '--55c<HH'UD,>,>,D$EEFF
r   c                     | j         S r   )r  r!   s    r   __hash__z_hash_limit_string.__hash__M  s
    zr   c                 B    t          |           t          |          k    S r   )r  )r   others     r   __eq__z_hash_limit_string.__eq__P  s    DzzT%[[((r   )r1   r2   r3   r4   r  r  r   r  r  s   @r   r  r  :  s`               ) ) ) ) ) ) )r   r  c                 H    t          j        | t          j        d           dS )zdIssue a warning.

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

    r   
stacklevelN)warningsr(   r	   	SAWarning)msgs    r   r(   r(   T  s#     M#s}333333r   c                 n    |rt          | d|          } t          j        | t          j        d           dS )z\Issue a warning with a parameterized string, limiting the number
    of registrations.

    
   r   r"  N)r  r$  r(   r	   r%  )r&  r   s     r   warn_limitedr)  ^  s<    
  0 b$//M#s}333333r   c                        g fd}|S )zNDecorate the given function to be a no-op after it is called exactly
    once.c                      }r;                                 }	  || i |S #  r                    d|            xY wd S )Nr   )r8  insert)r   r*  	strong_fnonce_fnr`   onceretry_on_exceptions       r   gozonly_once.<locals>.gon  sk     	 	hhjjGw*r***% ,KK7+++	 	s   # >r6   )r`   r0  r1  r/  s   `` @r   	only_oncer2  h  s8     4D       Ir   z%sqlalchemy/([a-z_]+/){0,2}[a-z_]+\.pyzunit(?:2|test2?/)c                 `   d}t          |           dz
  }||k    rA|                    | |                   r&|dz  }||k    r|                    | |                   &||k    rA|                    | |                   r&|dz  }||k    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_suffixrD   ends        r   chop_tracebackr9    s     E
b''A+C
3,,>00E;;,
 3,,>00E;;,
3,,>00C99,q 3,,>00C99,ecAgor   c                 |    d| z  }t                                                      }t          ||           |d         S )Nz&def set(obj, value):    obj.%s = valuerS   )rL  copyr   )attrnamer{   r   s      r   
attrsetterr=    s4    6AD
((--//CsOOO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                 B   | j         }|rj|D ]g}t          j        ||          }|rN||         }t          j        |          }|j        s+|                     |          x||<   }	t          | ||	           ht          t          |           
                    |||           d S r   )ensure_kwargr>   matchr   ro   r   
_wrap_w_kwrN  r  r?  r   )r@   clsnamer[   clsdictfn_regr?  r   r`   rv   wrappedr  s             r   r   zEnsureKWArgType.__init__  s    ! 	3 3 3HVS)) 3 B!8<<D: 3141C1CCwS'222os##,,WeWEEEEEr   c                 .    fd}t          |          S )Nc                       |  S r   r6   )r   r*  r`   s     r   wrapz(EnsureKWArgType._wrap_w_kw.<locals>.wrap  s    2s8Or   r   )r   r`   rJ  s    ` r   rC  zEnsureKWArgType._wrap_w_kw  s.    	 	 	 	 	 dB'''r   )r1   r2   r3   r4   r   rC  r  r  s   @r   r?  r?    sV         
F F F F F( ( ( ( ( ( (r   r?  c                 0   t          |d          rt          | |          S | }|j        j        |_        t          |d          r|j        |_        t          |j        d          r|j        j        r|j        j        |_        n|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   )rG   r   r  r1   r2   r   r4   )wrapperr`   _fs      r   wrap_callablerN    s     r: gr***l+2|$$ 	*MBM2;	** 	$r{/B 	$,BJJZ 	$BJ	r   c                    d| vr|                      d          S d}g g}d}t          |           }||k     r| |         }|dk    rE|dk    r9||dz
  k     r0| |dz            dk    r!|d                             d           |dz  }nC|dz  }n=|dk    r|dk    r|                    g            n|d                             |           |dz  }||k     d |D             S )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   c                 8    g | ]}d                      |          S ) )r=   )r:   r   s     r   r   z'quoted_token_parser.<locals>.<listcomp>  s"    ///uBGGENN///r   )r   r   rH   )r*   r%  rt  idxlvchars         r   quoted_token_parserrV    s   $ %{{3 ETF
C	UB
((Sz3;;zzcBFlluS1W~/D/Dr
!!#&&&q
S[[UaZZMM"2Jd###q (( 0/////r   c                 >     t          j                     fd}|S )Nc                 v    | j         d ur| j         pd}|rt          |fdD                       }|| _         | S )NrR  c                     i | ]}|S r6   r6   )r:   paramr  s     r   
<dictcomp>z8add_parameter_text.<locals>.decorate.<locals>.<dictcomp>  s    )J)J)J%%)J)J)Jr   )r4   inject_param_text)r`   r   paramsr  s     r   r}   z$add_parameter_text.<locals>.decorate  sT    j$39r 	L#C)J)J)J)J6)J)J)JKKC
	r   )r   r  )r]  r  r}   s   `` r   add_parameter_textr^     s9    !&))F      Or   c                     |                      dd          }t          |          dk    r| S |\  }}|                    d          s|dz   t          j        |          z   S t          j        |           S )Nr&   r   r%   )r   r   rH  textwrapdedent)r  
split_text	firstline	remainings       r   _dedent_docstringre    su    D!$$J
:!)	9$$ %4(/)"<"<<<t$$$r   c                 ,   t          | pd          } |                     d          }t          |          dk    r|                    d           t	          j        |                              d          }|d         r|                    dd           d t          |          D             }|                    dd           |t          |t          |          dz
                     }|d|         |z   ||d          z   }d	                    |          S )NrR  r&   r   r   c                 @    g | ]\  }}|                                 |S r6   )r  )r:   r  lines      r   r   z)inject_docstring_text.<locals>.<listcomp>"  s)    HHHic44::<<HcHHHr   )
re  r   r   rH   r`  ra  r,  r  minr=   )doctext
injecttextposlinesinjectlinesblanks
inject_poss          r   r   r     s   2..GMM$E
5zzQR/*--33D99K1~ "1b!!!HH9U#3#3HHHF
MM!QCVq112J!J,+-jkk0BBE99Ur   c                 8   |                                  }g }d }|r|                    d          }|t          j        d|          }|r|                    d          }||v rwdt          |                    d                    z  dz   }|rBt          j        d|d                   }	|	r%dt          |	                    d                    z  }|||         z   }n|                                                    d          rB|                    d           |                    |           |                    d           d }n|	                                sB|                    |           |                    |           |                    d           d }nT|
                    d	          r?|                    |           |                    |                    d                     |                    |           |d                    |          S )
Nr   z(\s+):param (?:\\\*\*?)?(.+?):r   r%   r   z(\s+)\Sz:param r&   z::)
splitlinesr8  r>   rB  r   r   lstriprH  rH   rstriprI  r=   )
rj  inject_paramsdoclinesrm  	to_injectrh  r   rZ  indentm2s
             r   r\  r\  +  s
   !!##HEI
 $||A:DAAA >

M)) 3qwwqzz??2S8F   <Xj(1+>> <%(3rxx{{+;+;%;F &u)= =I[[]]%%i00 	LLLL###LLII 	LLLL###LLII]]4   	 LLLLQ   TI  $L 99Ur   c                 *   t          |           dk    rdS t          |           dk    }|r
| dd         n| dd         | dd         z   } d | D             }|rd                    |          S d                    |dd                   d|d         S )	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   re   r   c                 R    g | ]$}t          |          d k    rd|dd          z  n|%S )   z%s..N)r   )r:   ri   s     r   r   z$repr_tuple_names.<locals>.<listcomp>`  s8    
L
L
LdTR6D"IT
L
L
Lr   r
  z, ..., )r   r=   )rw   flagress      r   repr_tuple_namesr  Y  s     5zzQtu::?D;E!A#JJE!A#Jrss$;E
L
Le
L
L
LC >yy~~ $		#ac( 3 3 3 3SWW==r   r   )FF)T)r6   Nr6   )NNrA  N)NNNr0   )TN)r  )Xr4   	functoolsr   r   rk   rT   ra  r>   r   r`  r   r$  rR  r   r   r	   r   r   r   rA   rL   r^   rb   r~   rr   r   r   r   r   r   r   rq   r   r   r   r  r  r;  r@  rV  rZ  rn  rp  r  r  r  r  r  r  r  r  r  r  r  r  re  propertyr  r  r  r  r  r1   r   r  r  r  r  	text_typer  r(   r)  r2  compile_SQLA_RE_UNITTEST_REr9  r   NoneTyper=  r?  rN  rV  r^  re  r   r\  r  r6   r   r   <module>r     s    % $ $ $ $ $        				 



                       .; .; .; .; .;6 .; .; .;b    M M M   , , ,>  
G G G GT'  '  '  '  ' 6 '  '  ' T
 
 
(( ( ( (V2 2 23; 3; 3; 3;lP
 P
 P
 P
fK K K K06 6 6$	 	 	EB EB EB EBP; ; ; ; ;f ; ; ;<0 0 0f  & 
		</ </ </ </~  S S S Sl% % % % % % % %,' ' '.+ + + + + + + +.%/ %/ %/ %/ %/F %/ %/ %/P   	 	 	    ' ' ' '(    "   B   C C C:    H   &
' 
' 
' 
' 
'V 
' 
' 
'
6 
6 
6 
6 
66 
6 
6 
6( ( ( ( (c ( ( (,  DL DL DL DL DLV DL DL DLN 
 
 
7 7 7   ) ) ) ) )) ) ) )44 4 44 4 4  , 2:>??rz.// '38    , 4::  ( ( ( ( (d ( ( (4  0)0 )0 )0X
 
 
	% 	% 	%  $+ + +\> > > > >r   