ҥq0OdZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl m Z ddl mZddl mZd ZGd d eZd Zd ZdZdZdZdZdZdZGddeZdZdZdZdZd[dZd\dZd\dZ dZ!dZ"d]d Z#Gd!d"eZ$d#Z%d$Z& d^d&Z'd'Z(d_d(Z)Gd)d*eZ*d+Z+Gd,d-eZ,Gd.d/eZ-d`d0Z.d1Z/d2Z0d3Z1dad4Z2d5Z3d6Z4dZd7Z5d8Z6d9Z7Gd:d;e8Z9Gd<d=eZ:Gd>d?eZ;Gd@dAe<Z=dBe=_>GdCdBeZ?da@dDZAdEZBdbdGZCGdHdIejDZEdJZFdKZGdLZHejIdMZJejIdNZKeKeJfdOZLeMdZNdPZOGdQdReMZPdSZQdTZRdUZSdVZTdWZUdXZVdYZWdS)czRoutines to help with the creation, loading and introspection of modules, classes, hierarchies, attributes, functions, and methods. update_wrapperN) _collections)compat)excctjr|d}tj}|||S)Nzutf-8)rpy3kencodehashlibmd5update hexdigest)xms /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/sqlalchemy/util/langhelpers.pymd5_hexrsE { HHW   AHHQKKK ;;==c*eZdZdZdZddZdZdZdS) safe_reraiseaKReraise 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||_dSN)r)selfrs r__init__zsafe_reraise.__init__8s "rc6tj|_dSr)sysexc_inforrs r __enter__zsafe_reraise.__enter__;srcB|3|j\}}}d|_|jstj||dSdStjs@|jr9|jdr,t d|jdd|jddd|_tj||dS)N)with_tracebackrz`An exception has occurred during handling of a previous exception. The previous exception is: r  )rrrraise_r warn)rtype_value tracebackexc_type exc_valueexc_tbs r__exit__zsafe_reraise.__exit__>s =*.. 'Hi!DN>  #)   ; 4> dnQ6G (,~a'8'8'8$.:K:K:KM "DN M% : : : : : :rNF)__name__ __module__ __qualname____doc__ __slots__rr"r/rrrr$sW"+I####(((;;;;;rrcpddtjd|jDS)Nr%c3>K|]}|VdSr)lower).0ns r z(clsname_as_plain_name..Vs; rz ([A-Z][a-z]+))joinrefindallr1)clss rclsname_as_plain_namerAUsC 88:&6 EE  rcg}|j|j|jfD];}t|dr|}||z!_unique_symbols..nsD3q66Mriz&exhausted namespace for symbol base %s)set itertoolschainritertools_imaprangeadd NameError)usedbasespoolsymrQs @r_unique_symbolsr^is t99D M M G  !"9"9"9"95;; G G   M MC$   DtKLL L M Mrc#LK|r||dzz}||V||z}|dSdS)z6Call the given function given each nonzero bit from n.rNr6)fnr;bs rmap_bitsrbysW  !aLbee  Q rc.fd}t|S)z'A signature-matching decorator factory.c4tj|s#tj|stdt j|}t |d|ddz|jfz}t|dd\}}t||}| t|d |j|d <d |z}t||||i|j}t|d |j|_||_t!||S) Nznot a decoratable functionrrtargetr`)rfr`FgroupednamezDdef %(name)s(%(args)s): return %(target)s(%(fn)s, %(apply_kw)s) im_func)inspect isfunctionismethod Exceptionrinspect_getfullargspecrIr1r^dictrformat_argspec_plus_exec_code_in_envgetattr __defaults__ __wrapped__r) r`specnames targ_namefn_namemetadatacode decoratedrfs rdecoratezdecorator..decorates(!"%% :g.>r.B.B :899 9,R00d1gac*bk^;,UHdCC 7yW555+D%@@@AAA;    & 9fgr2BK  ")Y!;!;!H  " i,,,rr)rfr}s` r decoratorr~s.-----2 (F + ++rc2t||||Sr)exec)r{envrys rrrrrssOOO w<rc t|tr|j}|}d|r|n d|jzd|d}n |x}}d|z}|dd}t j|}|dd=t|d }||d <d |z} |td } t| | | |} t|drG|j \} } | j }||j d|j}t|d| d|d|dd}|| _ n |j | _ d|dddz| _ | j t jvrt%d| j dt jst|dr0||j_ t|jds| |f|j_ n ||_ t|ds | |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. zConstruct 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..rFrgriz5def %(name)s(%(args)s): return cls(%(apply_kw)s) )r@symbol _linked_toNz[.. 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 sqlalchemyzpublic_factory location z is not in sys.modules__func__) isinstancetyperr1splitrrorqrrrGrr4r2inject_docstring_textrsplitrmodules ImportErrorpy2kr)rflocationclass_locationr` callable_doc location_namervrzr{rr| linked_tolinked_to_location linked_to_docs rpublic_factoryrsT&$ _ #1Mefo6MMM    Y .08 9 NN3''+M  ( , ,D Q "4777H$HV     v . .CsOOOM"Ir<  '(* % %!)  !(.(9(9(96??KN- M "!!888^^^  =    * J '(//#q*A*A!*DDI3;..k### &   {2gb*--2! r{L11 ;&/%:BK " r<(( 2&1BM rc(eZdZddZdZdZdZdS) PluginLoaderNc0||_i|_||_dSr)groupimplsauto_fn)rrrs rrzPluginLoader.__init__s   rc8|jdSr)rclearr!s rrzPluginLoader.clears rc||jvr|j|S|jr+||}|r||j|<|S ddl}||j|D]&}|j|j|<|cSn#t $rYnwxYwtjd|jd|)NrzCan't load plugin: :) rr pkg_resourcesiter_entry_pointsrloadrr NoSuchModuleError)rriloaderrimpls rrzPluginLoader.loads 4:  #4:d#%% % < \\$''F #) 4 vxx # &77 DII # ##'9 4 yy{{""" #    D ##*.***dd ;   sB B&%B&c*fd}||j|<dS)Nctj}dddD]}t||}t|S)Nrr)rimport_rrs)modtoken modulepathobjnames rrz#PluginLoader.register..loadsY.,,C#))#..qrr2 * *c5))3(( (r)r)rrirrrs `` rregisterzPluginLoader.registers6 ) ) ) ) ) )   4rr)r1r2r3rrrrr6rrrrsU    .     rrc  tj}|j}|j}t |jd|t |j|zfS#t$r4tj |}|dt |dfcYSwxYw)Nrr) rkCO_VARKEYWORDS__code__ co_argcountlist co_varnamesboolco_flagsAttributeErrorrro)r`co_varkeywordsconargsrvs r_inspect_func_argsr#s  /[ ' ( ( ~- . .   &&& ,R00AwT!W %%%% &s A;B  B c|du}|rt}|jdd}|o8t|tjot|jtj}|r-t|\}}| ||s|sdS|r|r|j D]}t||n| d|S)aeReturn 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 ! NrFr) rS__dict__getrtypes FunctionTyperCodeTyperr __bases__get_cls_kwargsdiscard)r@_settoplevelctrhas_initrwhas_kwcs rrr7st|Huu ,  :u - -C  5 sE. / / 5 s|U^ 4 4 *3// v E h 4 v  Aa&&./ LL Krc6tj|dS)zReturn the set of legal kwargs for the given `func`. Uses getargspec so is safe to call for methods, functions, etc. r)rrofuncs rget_func_kwargsrbs  ( . .q 11rFc tj|rtd|ztj|rq|r[|rYt j|}t j|jdd|j|j |j |j |j |j St j|Stj|r|rg|s|jr^t j|j}t j|jdd|j|j |j |j |j |j St j|jStj|rt%|j|dSt)|drt j|jSt)|drAtj|jrt%|j|Std |ztd |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. zCan't inspect builtin: %srNT)no_self_is_initr__call__)rzCan't inspect callable: %s)rk isbuiltin TypeErrorrlrro FullArgSpecargsvarargsvarkwdefaults kwonlyargskwonlydefaults annotationsrm__self__risclassget_callable_argspecrrGr)r`rrrvs rrrms*;3b8999  B  (;  5 5044D% !""    #  044 4  "  ;  > >BK >0==D% !""    #  0== =    ;# K4     Z ;,R[999 Z ;  BK ( ( ?' WEEE E82=>> >4r9:::rTctj|rtj|}n|}tj|}|dr|dd}n|dr d|dz}nd}tj|d|d|dd|d}d}|dr|t |dz }|dr|t |dz }|d|dz}|r|d|z d}nd}tj||d|d|d } |rt |||| St |dd ||dd | dd  S) aReturns 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)'} rrz%s[0]Nrrer6c d|zS)N=r6)rs rrRz%format_argspec_plus..s cAgr) formatvalue)rself_arg apply_posapply_kwr)rcallableroinspect_formatargspeclenrp) r`rhrvrrr num_defaults name_argsdefaulted_valsrs rrqrqs@r,R00  ' .D Aw71: aT!W$, Qa$q'4aIL Aw%DG $  Aw%DG $ Q$q'!I"1|#3#5#56+ Q Q%% H       ad"oad^     rc|tjur|rdpd}n( t||S#t$r |rdpd}YnwxYwt 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)rrgz(self, *args, **kwargs)zself, *args, **kwargs)rrrr)objectrrqrrp)methodrhrs rformat_argspec_initrs  #8-v &vw??? ?   .-+* DD  ddT J J JJs (;;c tj|S#t$r!|tjur dgdddfcYSdgdddfcYSwxYw)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) rNrkwargs)rrorrr)rs rgetargspec_initrsn6,V444 666 V_ $ $HdD$/ / / /Hfh5 5 5 5 6sAAAcVt|tjr|js|jS|S)zSAdjust the incoming callable such that a 'self' argument is not required. )rr MethodTyperr) func_or_clss runbound_method_to_callabler s2 +u/009M##rr6c V|g}ntj|}tg}tj}d}t |D]\}} t j|j} | jrt| jpd} |dkrW| j r| j }| r$| | j d| nR| | j ddn/| fd| j d| D| r@| dt| j | d| jD #t$rYwxYwg} | fd|D|=t!|r-| dt#|D|D]P\} } | |vr t#| }|ur || kr| | d|A#t($rYMwxYw|rN|D]K\} } t#| }|ur || kr| | d|<#t($rYHwxYwjjd d | d S) z}Produce a __repr__() based on direct association of the __init__() specification vs. same-named attributes present. Nrrcg|]}|fSr6r6)r:argmissings r z generic_repr..KsIIIc7^IIIrcg|] \}}||f Sr6r6)r:rdefaults rrz generic_repr..Ps0(Cgrc3TK|]"}tt|dV#dSr)reprrs)r:robjs rr<zgeneric_repr..Ys7DDC$wsC..//DDDDDDrc,g|]}t|Sr6r)r:vals rrz generic_repr..\s@@@StCyy@@@rr(, ))rto_listr OrderedDict enumeraterrorrrrextendrrziprrGrsitemsrHrn __class__r1r=)r additional_kw to_inspect omit_kwargpos_argskw_argsvargsrPinsprv default_lenoutputrdefvalrrs` @r generic_reprr,s[ U !)*55 hhGH&((G EZ((4 0??D->C ,>,>C!KAvv<) LE3OODIa n$=>>>>OODIabbM2222IIIItyK</HIII ,/ I{lmm4dm--#    H 2F MMDDDD8DDDDDD WS%00 @@GC,?,?@@@AAA}} V *    #sG,,C'!!cVmm cc2333    D (  KC c300g%%#--MMSSS##"6777    }---tyy/@/@/@/@ AAs6E E,+E,05H&& H32H35I66 JJc0eZdZdZdZdZdZd dZdZdS) portable_instancemethodz_Turn an instancemethod into a (parent, name) pair to produce a serializable callable. )rfrir __weakref__c,|j|j|jdS)Nrfrirr"r!s r __getstate__z$portable_instancemethod.__getstate__|s kIk   rcp|d|_|d|_|dd|_dS)Nrfrirr6)rfrirr)rstates r __setstate__z$portable_instancemethod.__setstate__s1Ho &M ii"-- rr6cD|j|_|j|_||_dSr)rrfr1rir)rmethrs rrz portable_instancemethod.__init__sm M  rcv||jt|j|j|i|Sr)rrrsrfri)rrkws rrz portable_instancemethod.__call__s9 $+.wt{DI..:r:::rNr6) r1r2r3r4r5r#r&rrr6rrrrtsf :I   ...  ;;;;;rrc tjr(t|tjrt S|ht |j}|r&|}tjr/t|tjr>fd|jD}nfd|jD}|D],}| | |-tj r|j dkst|dsn|j dkst|dsوfd|DD],}| | |-|&t S)aReturn 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. c3XK|]$}|vt|tj |V%dSr)rr ClassTyper:_hiers rr<z"class_hierarchy..sED==Au)G)G= ===rc3$K|] }|v|V dSrr6r/s rr<z"class_hierarchy..s'==1q}}Q}}}}==rbuiltins__subclasses__ __builtin__cg|]}|v| Sr6r6r/s rrz#class_hierarchy..sAAA1D==!===r)rrrrr.r__mro__poprrHrXr r2rGr4)r@processrr[rasr1s @rclass_hierarchyr;s{ c5? + + 66M 5D3;G  KKMM ; >!U_-- EE >=== ===E  A NN1    HHQKKKK ; |z)).sl     T""  JJt$$   !,,  TMM  "MMrrrjrrz(self, *args, **kw)z (*args, **kw)z?def %(method)s%(fn_args)s: return %(name)s.%(method)s%(d_args)s) r=rsrGrrrorrlocalsexec_rtsetattr)rJfrom_clsrKonlyri from_instancedundersrr`rvfn_argsd_argspyrs` ` rmonkeypatch_proxied_specialsrVs   <D      ]]    // 6**B2z** Y++BB    H  %044D247;;G1$q'!""+>>FF % % %+G$FFF %  35;XX > 4'AT=,AGR R ')CK $ $    D &#f+....7//s< A!A!! A.-A.2ACCCD D('D(cFt|d|t|d|uS)z;Return True if the two methods are the same implementation.r)rs)meth1meth2s rmethods_equivalentrZs0 5*e , , z511 rc `|s|stdt|trt||r|St|pdt |D}tt |}t j}t|tr|}n,|st}t j}nt|}||||r|St|ts<|t jurdpd}t|d|dd |Gdd t}|rd |j z|_ t} t|D]w\} } | |vrtd | ztj| st| d | d t!|| t#| | | x|| |r|Stdd || z z)aEnsure 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:rs rrz as_interface..Cs)MMMa1<<;L;LMMMMrzany ofzall ofz does not implement z: r ceZdZdZdS)(as_interface..AnonymousInterfacezA callable-holding shell.N)r1r2r3r4r6rrAnonymousInterfacer^Zs''''rr_ Anonymousz%r: unknown in this interfacerz is not callablez,dictionary does not contain required keys %s)rrrrSr=operatorgegt intersectionrpr=rr1dictlike_iteritemsrrrN staticmethodrX) rr@methodsrequired interface implementedcomplies qualifierr_foundrrs r as_interfacerns~B NwNLMMM#tC!5!5 GMMM3s88MMMNNIc#hh--K{H(D!!! !55;x==x ((33X>>  c4   +8DH ssIIItyy333 5   (((((V((( A&1CL&@# EEE*3//   " ";fDEE Et$$ FvvvtttDEE E"FL,>,>??? &xx  "!! 6 ))Hu$ % % &  rc<eZdZdZddZdZdZedZdS)memoized_propertyz2A read-only @property that is only evaluated once.NcH||_|p|j|_|j|_dSr)fgetr4r1)rrrrs rrzmemoized_property.__init__us$ *dl   rcV||S||x|j|j<}|Sr)rrrr1)rrr@results r__get__zmemoized_property.__get__zs. ;K/3yy~~= T]#f rcFt||jdSr)rpresetr1)rrs r_resetzmemoized_property._resets T]33333rc<|j|ddSr)rr8)r@rris rrwzmemoized_property.resets  t$$$$$rr) r1r2r3r4rrurx classmethodrwr6rrrprprsg<<&&&&  444%%[%%%rrpc.fd}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. cz|g|Ri|fd}j|_j|_||jj<S)NcSrr6ar*rts rmemoz6memoized_instancemethod..oneshot..memosMr)r1r4r)rrr*rrtr`s @roneshotz(memoized_instancemethod..oneshotscD&4&&&2&&       z %) bk" rr)r`rs` rmemoized_instancemethodrs.      '2 & &&rc,eZdZdZddZdZdZdZdS) !group_expirable_memoized_propertyz?A family of @memoized_properties that can be expired in tandem.r6cPg|_|r|j|dSdSr) attributesr)rrs rrz*group_expirable_memoized_property.__init__s7  / O " ": . . . . . / /rcT|j}|jD]}||ddS)z.Expire all memoized properties for *instance*.N)rrr8)rinstancestash attributes rexpire_instancez1group_expirable_memoized_property.expire_instances<! ' 'I IIi & & & & ' 'rc^|j|jt|Sr)rrHr1rprr`s rrz*group_expirable_memoized_property.__call__s( r{+++ $$$rc^|j|jt|Sr)rrHr1rrs rrz(group_expirable_memoized_property.methods( r{+++&r***rNr+)r1r2r3r4rrrrr6rrrrs[II//// ''' %%%+++++rrc"eZdZdZdZdZdZdS) 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__. r6c t|r)r)rr?s r_fallback_getattrzMemoizedSlots._fallback_getattrsS!!!rcrdrttdzr.tdz}t ||Stdzr(tdzfd}j|_|SS)N _memoizedz_memoized_attr_%sz_memoized_method_%scv|i|fd}j|_j|_t|S)NcSrr6r~s rrz8MemoizedSlots.__getattr__..oneshot..memos!Mr)r1r4rN)rr*rrtr`r?rs @rrz*MemoizedSlots.__getattr__..oneshotsYTR"""""!#  !z c4((( r)rHrrGrsrNr4r)rr?r*rr`s`` @r __getattr__zMemoizedSlots.__getattr__s >>+ & & / %% % T.4 5 5 />E D#u % % %L T036 7 7 /4s:;;B       !jGON))#.. .rN)r1r2r3r4r5rrr6rrrrsCI"""/////rrcfd}|S)Ncd}tjd|ddt t |dg}t ||d}t||j|r/t|dr|j |j|S)Nrrr__all__) rrrr=globalsrLrsrNr1rGrrH)rtokensr add_to_all modulenames rr}z dependency_for..decorates!!#&&n HHVAbD\ " "GIIvxx&*  c6":&&S\3'''  -'#y11 - K  s| , , , rr6)rrr}s`` rdependency_forrs)       Orct|tjrD|}|dvrdS|dvrdSt d|zt |S)N)trueyesonyt1T)falsenooffr;f0FzString is not true/false: %r)rr string_typesstripr9 ValueErrorr)rs rasboolrss#v*++Ciikk!! 6 6 64 9 9 95;cABB B 99rcfd}|S)zqReturn a callable that will evaluate a string as boolean, or one of a set of "alternate" string values. c.|vr|St|Sr)r)rtexts r bool_or_valuez"bool_or_str..bool_or_values $;;J#;; rr6)rrs` r bool_or_strrs$  rc(||St|S)zCoerce to integer.)int)r*s rasintrs } u::rc||}||vrnt|trt|||sG||=|tur|rt||||<dS|||||<dSdSdSdS)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)rrrr)r*r?r) flexi_booldests rcoerce_kw_typers  | r E4(( 0:2c7E0J0J  sG  D==Z=r#wDIIIbgDIII     rct|}|fd||D||i|S)zInstantiate cls using the __dict__ of obj as constructor arguments. Uses inspect to match the named arguments of ``cls``. c3HK|]}|jv |j|fVdSr)r)r:krs rr<z#constructor_copy..,sC!"a3<>O>OCLO>O>O>O>Or)rr difference)rr@rr*rws` rconstructor_copyr$ss 3  EII&+&6&6r&:&: 3   rcztjtjdfd}|S)z%Return a threadsafe counter function.rc tS#wxYwr)acquirenextrelease)counterlocksr_nextzcounter.._next9s?  == LLNNNNDLLNNNNs :A)r threadingLockrTcount)rrrs @@rrr2sN   " "Doa  G Lrct|dr/|j!t|jtrtS|jSt |t rtpt}||t rt S||trtS||trtSt|drt St|drtSt|drtS|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__NrHrXrS)rGr issubclassrSrrrrp)specimenrisas rduck_type_collectionrCs x(()  ,  !32 2 ,J( ( Xt $ $ 3 AzC s8T Xs   Xt   x"" 5 ! ! 5 ! ! rc 6t||r|St|trHtjd|ddd|Ddt |dtjd|d|dt |d) Nz Argument 'z ' is expected to be one of type z or c3 K|] }d|zV dS)z'%s'Nr6)r:rs rr<z"assert_arg_type..ks&$A$AAVaZ$A$A$A$A$A$Arz, got ''z' is expected to be of type 'z', got ')rrIr ArgumentErrorr=r)rargtyperis rassert_arg_typerds#w  gu % % ##44$A$A$A$A$AAAAA49999N  ##44$s))))- rc rtjr2tdr!tSnUtdrStdr!t Stdtddtdztdrfd}|Std r-t fd  DStdz) z?Return a (key, value) iterator for almost any dict-like object.r iteritems __getitem__rNzObject '%r' is not dict-likeiterkeysc3XKD]}||fVdSr)r)r?dictlikegetters riteratorz$dictlike_iteritems..iteratorsH((** ' '66#;;&&&&& ' 'rr>c32K|]}||fVdSrr6)r:r?rs rr<z%dictlike_iteritems..s0BB3S&&++&BBBBBBr) rr rGrrriterrsrr>)rrrs` @rreretsV{* 8W % % *(()) ) * 8[ ) ) *%%'' ' Xw ' ' *(()) ) X}ght.L.L M MF ~6ABBBx$$ C ' ' ' ' ' 'xzz 6 " "CBBBB(--//BBBBBB6ABBBrc(eZdZdZfdZdZxZS) classpropertyaAA 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. chtt|j|g|Ri||j|_dSr)superrrr4)rrrrr*rs rrzclassproperty.__init__s=+mT""+D=3==="===| rc,||Sr)rr)descrr@s rruzclassproperty.__get__syy~~r)r1r2r3r4rru __classcell__rs@rrrsQ$$$$$rrceZdZdZdZdS)hybridpropertyc||_dSrrrrs rrzhybridproperty.__init__  rc|(||}|jj|_|S||Sr)rr4)rrownerclsvals rruzhybridproperty.__get__s<  YYu%%F!Y.FNM99X&& &rN)r1r2r3rrur6rrrrs2'''''rrceZdZdZdZdZdS) hybridmethodz/Decorate a function as cls- or instance- level.c||_dSrrrs rrzhybridmethod.__init__rrc|| |j||jS|j||Sr)rrur)rrrs rruzhybridmethod.__get__s:  9$$UEO<< <9$$Xu55 5rN)r1r2r3r4rrur6rrrrs89966666rrc(eZdZddZdZdZdZdS)_symbolNct|tjsJ|t|}tt |}||_|r||_|S)zConstruct a new named symbol.) rrrhashr__new__rrir4)rrir canonicalvs rrz_symbol.__new__sZ$ 344444  T I KK + +  AIrc>t|jdt|ffS)Nr)rrirr!s r __reduce__z_symbol.__reduce__s 3D 222rc t|Srrr!s r__str__z_symbol.__str__sDzzrcd|jzS)Nz symbol(%r))rir!s r__repr__z_symbol.__repr__sdi''rNN)r1r2r3rrrrr6rrrrsU    333(((((rrrcjeZdZdZiZejZddZ e ddZ dS)raA constant symbol. >>> symbol('foo') is symbol('foo') True >>> 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 jS#t jwxYwr)_lockrsymbolsrrrr)r@rirrr]s rrzsymbol.__new__s  #+//$''C{*1$Y*G*GG D!C L " " " "FL " " " "s 8A22 BFc|D]&\}}||ur|cS|r||jkr|cS||vr|cS'|dStjd|d|)aGiven 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. NzInvalid value for 'z': )rrir r)r@rchoicesriresolve_symbol_namesr]choices rparse_user_argumentzsymbol.parse_user_arguments,#==??  KCczz % #//   ;4cc JKKKrrr0) r1r2r3r4rrrrrrrzr r6rrrrsv*G   ! ! # #E####6; L L L[ L L Lrc2t|_tdz adS)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). rN)_creation_order)rs rset_creation_orderr!s /HqOOOrc ||i|S#t$r/tdtjddzYdSwxYw)zXexecutes the given function, catches all exceptions and converts to a warning. z%s('%s') ignoredrrN)rnr(rr )rrrs rwarn_exceptionr.sc 7tT$V$$$ 777 #,..1"5 56666667s 5AAcl t||kr d|d|zS|S#t$r|cYSwxYw)Nz%s...r)rr)r*len_s rellipses_stringr9sT u::  U1T6]* *L  s$$ 33c.eZdZdZfdZdZdZxZS)_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||zd|zz}tt|||}td|t||zfz|_|S)Nz6 (this warning may be suppressed after %d occurrences)z%s_%d)rrrr_hash)r@r*numr interpolatedrrs rrz_hash_limit_string.__new__Nsf Ds J '--55c<HH'UD,>,>,D$EEFF  rc|jSr)rr!s r__hash__z_hash_limit_string.__hash__Vs zrcBt|t|kSr)r)rothers r__eq__z_hash_limit_string.__eq__YsDzzT%[[((r)r1r2r3r4rrr rrs@rrrCs`)))))))rrcHtj|tjddS)zdIssue a warning. If msg is a string, :class:`.exc.SAWarning` is used as the category. r stacklevelN)warningsr(r SAWarning)msgs rr(r(]s# M#s}333333rcn|rt|d|}tj|tjddS)z\Issue a warning with a parameterized string, limiting the number of registrations. rr"N)rr$r(r r%)r&rs r warn_limitedr)gs<  0 b$// M#s}333333rc gfd}|S)zNDecorate the given function to be a no-op after it is called exactly once.c}r;} ||i|S#rd|xYwdS)Nr)r8insert)rr* strong_fnonce_fnr`onceretry_on_exceptions rgozonly_once..gowsk  hhjjG w*r*** %,KK7+++  s#>r6)r`r0r1r/s`` @r only_oncer2qs8 4D        Irz%sqlalchemy/([a-z_]+/){0,2}[a-z_]+\.pyzunit(?:2|test2?/)c`d}t|dz }||krA|||r&|dz }||kr|||&||krA|||r&|dz}||kr|||&|||dzS)atChop 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`` rr)rsearch)tbexclude_prefixexclude_suffixrDends rchop_tracebackr9s E b''A+C 3,,>00E;;,   3,,>00E;;, 3,,>00C99, q 3,,>00C99, ecAgo rc|d|z}t}t|||dS)Nz&def set(obj, value): obj.%s = valuerS)rLcopyr)attrnamer{rs r attrsetterr=s4 6 AD ((--//CsOOO u:rc(eZdZdZfdZdZxZS)EnsureKWArgTypezYApply translation of functions to accept \**kw arguments if they don't already. cB|j}|rj|D]g}tj||}|rN||}tj|}|js+||x||<} t||| htt| |||dSr) ensure_kwargr>matchrror _wrap_w_kwrNrr?r) r@clsnamer[clsdictfn_regr?rr`rvwrappedrs rrzEnsureKWArgType.__init__s!  3 3 3HVS))3 B!8<.wraps2s8Orr)rr`rJs ` rrCzEnsureKWArgType._wrap_w_kws.     dB'''r)r1r2r3r4rrCrrs@rr?r?sV F F F F F(((((((rr?c0t|drt||S|}|jj|_t|dr |j|_t|jdr|jjr|jj|_n|jr |j|_|S)zAugment functools.update_wrapper() to work with objects with a ``__call__()`` method. :param fn: object with __call__ method r1r2r4)rGrrr1r2rr4)wrapperr`_fs r wrap_callablerNsr: gr*** l+ 2| $ $ *MBM 2; * * $r{/B $,BJJ Z $BJ rcd|vr|dSd}gg}d}t|}||kr||}|dkrE|dkr9||dz kr0||dzdkr!|dd|dz }nC|dz}n=|dkr|dkr|gn|d||dz }||kd|DS)aParse 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'] "rrrrc8g|]}d|S))r=)r:rs rrz'quoted_token_parser..s" / / /uBGGENN / / /r)rrrH)r*r%rtidxlvchars rquoted_token_parserrVs$ %{{3 ETF C UB ((Sz 3;;zzcBFlluS1W~/D/Dr !!#&&&q  S[[UaZZ MM"     2J  d # # # q (( 0 / / / //rc>tjfd}|S)Ncv|jdur|jpd}|rt|fdD}||_|S)NrRci|]}|Sr6r6)r:paramrs r z8add_parameter_text..decorate..s)J)J)J%%)J)J)Jr)r4inject_param_text)r`rparamsrs rr}z$add_parameter_text..decorate sTj$39r  L#C)J)J)J)J6)J)J)JKKC  r)rr )r]rr}s`` radd_parameter_textr^ s9  !& ) )F Orc|dd}t|dkr|S|\}}|ds|dztj|zStj|S)Nr&rr%)rrrHtextwrapdedent)r split_text firstline remainings r_dedent_docstringresuD!$$J :! ) 9    $ $%4(/)"<"<<<t$$$rc,t|pd}|d}t|dkr|dt j|d}|dr|dddt|D}|dd|t|t|dz }|d||z||dz}d |S)NrRr&rrc@g|]\}}||Sr6)r)r:rlines rrz)inject_docstring_text..+s) H H Hic44::<< Hc H H Hr) rerrrHr`rar,rminr=)doctext injecttextposlines injectlinesblanks inject_poss rrr"s 2..G MM$  E 5zzQ R/*--33D99K1~"1b!!! H H9U#3#3 H H HF MM!QCVq112J !J, + -jkk0B BE 99U  rc8|}g}d}|r|d}|tjd|}|r|d}||vrwdt |dzdz}|rBtjd|d} | r%dt | dz}|||z}n|drB|d|||dd}n| sB|||||dd}nT| d r?||||d|||d |S) Nrz(\s+):param (?:\\\*\*?)?(.+?):rr%rz(\s+)\Sz:param r&z::) splitlinesr8r>rBrrlstriprHrHrstriprIr=) rj inject_paramsdoclinesrm to_injectrhrrZindentm2s rr\r\4s !!##H EI $||A  :DAAA > M)) 3qwwqzz??2S8F <Xj(1+>><%(3rxx{{+;+;%;F &u)= =I [[]] % %i 0 0  LL    LL # # # LL   II  LL    LL # # # LL   II ]]4   LL    LL Q     TI $L 99U  rc*t|dkrdSt|dk}|r |ddn|dd|ddz}d|D}|rd|Sd|ddd|dS) zTrims a list of strings from the middle and return a string of up to four elements. Strings greater than 11 characters will be truncatedrNrrercRg|]$}t|dkr d|ddzn|%S) z%s..N)r)r:ris rrz$repr_tuple_names..is8 L L LdTR6D"I  T L L Lrr z, ..., )rr=)rwflagress rrepr_tuple_namesrbs 5zzQt u::?D ;E!A#JJE!A#Jrss$;E L Le L L LC >yy~~ $ #ac( 3 3 3 3SWW==rr)FF)T)r6Nr6)NNrAN)NNNr0)TN)r)Xr4 functoolsrr rkrTrar>rr`rr$rRrrr rrrrArLr^rbr~rrrrrrrrrqrrrrrr;r@rVrZrnrprrrrrrrrrrrrrepropertyrrrrrr1rrrrr text_typerr(r)r2compile_SQLA_RE _UNITTEST_REr9rNoneTyper=r?rNrVr^rerr\rr6rrrs%$$$$$  .;.;.;.;.;6.;.;.;b    M M M ,,,> PPPPf' ' ' ' ' 6' ' ' T   (((((V2223;3;3;3;lP P P P fKKKK0666$   EBEBEBEBP;;;;;f;;;<000f   &   </</</</~SSSSl%%%%%%%%,'''.++++++++.%/%/%/%/%/F%/%/%/P          ''''(   "B    CCC:H& ' ' ' ' 'V ' ' ' 6 6 6 6 66 6 6 6(((((c(((,DLDLDLDLDLVDLDLDLN   777)))))))))4444444, 2:> ? ?rz.// '38, 4::(((((d(((40)0)0)0X    % % %$+++\ > > > > >r