Тa`dZddlmZddlZddlmZddlmZddlmZdd lm Z ej e Z d Z d Zd ZGd deZGddeZee_GddeZGddeZGddeZGddeZGddeeZdS)z@Path tracking utilities, representing mapper graph traversals. )chainN) class_mapper)exc) inspection)utilc6t|SN) PathRegistry deserializepaths p/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib64/python3.11/site-packages/sqlalchemy/orm/path_registry.py_unreduce_pathrs  # #D ) ))* _sa_defaultc$eZdZdZdZdZdZdZdZdZ dZ dd Z d Z e d Zd Zd ZdZdZedZedZedZedZdZedZedZedZdZdZdZdS)r aRepresent query load paths and registry functions. Basically represents structures like: (, "orders", , "items", ) These structures are generated by things like query options (joinedload(), subqueryload(), etc.) and are used to compose keys stored in the query._attributes dictionary for various options. They are then re-composed at query compile/result row time as the query is formed and as rows are fetched, where they again serve to compose keys to look up options in the context.attributes dictionary, which is copied from query._attributes. The path structure has a limited amount of caching, where each "root" ultimately pulls from a fixed registry associated with the first mapper, that also contains elements for each of its property keys. However paths longer than two elements, which are the exception rather than the rule, are generated on an as-needed basis. Fc |duo|j|jkS#t$r(tjdt |zYdSwxYw)N1Comparison of PathRegistry to %r is not supportedFrAttributeErrorr warntypeselfothers r__eq__zPathRegistry.__eq__>si $@ej)@ @    IC;;    55  .AAc |dup|j|jkS#t$r(tjdt |zYdSwxYw)NrTrrs r__ne__zPathRegistry.__ne__Hsh D=;DI$; ;    IC;;    44  r!cXtd|||||||jf<dS)Nzset '%s' on path '%s' to '%s')logdebug natural_pathr attributeskeyvalues rsetzPathRegistry.setRs3 13eDDD/4 C*+,,,rcztd||||||jf|dS)Nz$setdefault '%s' on path '%s' to '%s')r%r& setdefaultr'r(s rr.zPathRegistry.setdefaultVs? 8#tUKKKsD$56>>>>>rNc0||jf}||vr||S|Sr )r'r(s rgetzPathRegistry.getZs)D%& *  c? "Lrc*t|jSr lenrrs r__len__zPathRegistry.__len__as49~~rc*t|jSr r2r4s rlengthzPathRegistry.lengthds49~~rc#K|j}tdt|dD]}||||dzfVdS)Nrrr)rranger3)rris rpairszPathRegistry.pairshsXyq#d))Q'' ' 'Aq'4A;& & & & & ' 'rcfdtdtjdDD]!}|jr||rdS"dS)Nc*g|]}j|Srr).0r:rs r z0PathRegistry.contains_mapper..nsNNNQDIaLNNNrrrTF)r9r3r is_mapperisa)rmapper path_mappers` rcontains_mapperzPathRegistry.contains_mappermseNNNN%3ty>>12M2MNNN  K$ )@)@ tt5rc||jf|vSr r)rr)r*s rcontainszPathRegistry.containstsTY:--rc:t|ffSr )r serializer4s r __reduce__zPathRegistry.__reduce__ws 0 0222rc ttdfdtdtdDDfdtdtdDdgzS)Ncg|] }|j Sr)class_)r>ms rr?z0PathRegistry._serialize_path..~sMMMaMMMrc g|] }| Srrr>r:rs rr?z0PathRegistry._serialize_path..~s#L#L#LDG#L#L#Lrrrc*g|]}|jSr)r*rOs rr?z0PathRegistry._serialize_path..s===a===rr)listzipr9r3)clsrs `r_serialize_pathzPathRegistry._serialize_pathzs MM#L#L#L#LU1c$ii5K5K#L#L#LMMM====eAs4yy!&<&<===F     rcnttd|D}|r|d |dd}|S)Ncng|]2\}}t||t|j|ndf3Sr )rattrs)r>mclsr*s rr?z2PathRegistry._deserialize_path..s["c %T**?%T**055! rr)tuplerrSrps r_deserialize_pathzPathRegistry._deserialize_paths[  &*    2!B$Arc^fdfd|DDS)NcNg|]!\\}}}||f|f"Sr)rTr>r*rr+rSs rr?z7PathRegistry.serialize_context_dict..sI   " dU3&&t,, -u 5   rc\g|](\}}t|tr|dv$||f)S)r) isinstancerZ)r>kvtokenss rr?z7PathRegistry.serialize_context_dict..sJ'''Aqa'''-.aDFNNA,:NNr)items)rSdict_res` `rserialize_context_dictz#PathRegistry.serialize_context_dictsZ    ''''!KKMM'''    rcDtjfd|DS)Nc3pK|]0\\}}}|t|f|fV1dSr )rZr]r`s r z8PathRegistry.deserialize_context_dict..s_  " dU5..t4455 6 >      r)r OrderedDict)rS serializeds` rdeserialize_context_dictz%PathRegistry.deserialize_context_dicts>    &0      rc:|j}||Sr )rrT)rrs rrHzPathRegistry.serializesy##D)))rc^|dS||}||Sr )r]coercer[s rr zPathRegistry.deserializes/ <4  ! !$ ' 'zz!}}rcd|jrt|j|St|j|Sr )r@CachingEntityRegistryrootSlotsEntityRegistry)rSrBs r per_mapperzPathRegistry.per_mappers1   9(6:: :&sx88 8rc:tjd||jS)Nc||Sr rprevnexts rz%PathRegistry.coerce.. d4jr)r reducert)rSraws rrqzPathRegistry.coerces{88#sxHHHrc|dtzrt||S|dtzrt|j|St jd|z)N:zinvalid token: %s)endswith_WILDCARD_TOKEN TokenRegistry_DEFAULT_TOKENrtr ArgumentError)rtokens rrzPathRegistry.tokenso >>#/ 0 0 A u-- - ^^C.0 1 1 A E22 2#$7%$?@@ @rc:tjd|j|S)Nc||Sr rrys rr|z&PathRegistry.__add__..r}r)r r~rrs r__add__zPathRegistry.__add__s{88%*dKKKrc0|jjd|jdS)N()) __class____name__rr4s r__repr__zPathRegistry.__repr__s>222DIII>>rr )r __module__ __qualname____doc__ __slots__is_tokenis_rootr r#r,r.r0r5propertyr7r;rDrFrI classmethodrTr]rhrnrHr rvrqrrrrrrr r s2IHG555???X''' ...333  [ [$  [   [ ***[ 99[9 II[IAAALLL?????rr c,eZdZdZdxZZdZdZdZdZ dS) RootRegistryzXRoot registry, defers to mappers so that paths are maintained per-root-mapper. rFTc|jSr )_path_registryrentitys r __getitem__zRootRegistry.__getitem__s $$rN) rrrrrr' has_entityis_aliased_classrrrrrrrsI D<JG%%%%%rrc,eZdZdZdZdZdZdZdZdS)rrparentrr'cb||_||_|j|fz|_|j|fz|_dSr r)rrrs r__init__zTokenRegistry.__init__s8  K5(* "/5(:rFTc#K|jjsV|jjsJ|jjD])}t |jj||jV*dS|jjrR|jjjrA|V|jjj D])}t |jj||jV*dS|VdSr ) rrrrBiterate_to_rootrrr_is_with_polymorphic_with_polymorphic_entities)rents rgenerate_for_superclassesz'TokenRegistry.generate_for_superclassess{+ DK4G {)99;; I I#DK$6s$;TZHHHHHH I I K (  "7 JJJ{)D I I#DK$6s$;TZHHHHHH I IJJJJJrctr )NotImplementedErrorrs rrzTokenRegistry.__getitem__s!###rN) rrrrrrrrrrrrrrsR;I;;; JH   $$$$$rrceZdZdZdZdZejdZejdZ e dZ e dZ dZ d S) PropRegistryFctj|d}|}|jr|jr|j|jx}}n|jrf|jr_|j|jvrQ|d|j}|j|}|jr|j|j}d|_nP|}nM|jrF|jr?|j|jur1|j |jr|j|j}||_ ||_|j |fz|_ |j |fz|_ d|j |j j zf|_|j j|_d|j f|_dS)NrYTloader)rinspectr_use_mapper_pathrwith_polymorphic_mappers_entity_for_mapperrB is_unnaturalrAproprr'_wildcard_token_wildcard_path_loader_key_default_path_loader_key _loader_key)rrrinspnatural_parentsubclass_entitys rrzPropRegistry.__init__s!&*--$4 8(=4 8&,mDK&@ @F^^  !2 8-2 8 t<<<$Rj;;DKHHO]?3F@} (!'/E!F$(!!!'  ! 8% 8 ;  ,,$]4;7N  K4') *74'A  K$)3 3* &)- (J%$di0rcJdd|jDS)Nz -> c34K|]}t|VdSr )str)r>elems rrkz'PropRegistry.__str__..Js(;;3t99;;;;;;r)joinrr4s r__str__zPropRegistry.__str__Is%{{;;;;;;;;rc,t|jdS)NrB)hasattrrr4s rrzPropRegistry.has_entityLsty(+++rc|jjSr )rrBr4s rrzPropRegistry.entityPs yrc|jSr rr4s rrBzPropRegistry.mapperTs {rc||jSr rr4s r entity_pathzPropRegistry.entity_pathXsDK  rctt|ttfr |j|St ||Sr )rbintslicerrurs rrzPropRegistry.__getitem__\s5 fsEl + + 59V$ $&tV44 4rN)rrrrrrr memoized_propertyrrrrBrrrrrrrsLF1F1F1P<<< ,,,    X!!X!55555rrcXeZdZdZdZdZedZedZdZ e Z dZ dS) AbstractEntityRegistryrTcp||_||_|j|_||_|j|fz|_|jrq|js|jrc|j|jdjr|j|jfz|_dS|j|jdjfz|_dS|j|_dS)NrY) r*rrrrrrBrAr')rrrs rrzAbstractEntityRegistry.__init__hs & 7 K6)+  ; *D1 *V5H *}  !4R!8!?@@ $*$76=:J$J!!!$*$7'+2;%!!!!% D   rc|Sr rr4s rrz"AbstractEntityRegistry.entity_paths rc>tj|jjSr )rrrrBr4s rrBzAbstractEntityRegistry.mappers!$+..55rcdS)NTrr4s r__bool__zAbstractEntityRegistry.__bool__strctt|ttfr |j|St ||Sr )rbrrrrrs rrz"AbstractEntityRegistry.__getitem__s5 fsEl + + .9V$ $f-- -rN) rrrrrrrrrBr __nonzero__rrrrrrcsIJ***@X66X6K.....rrceZdZdZdS)ru)r*rrrrr'N)rrrrrrrrurusIIIrruceZdZdZdZdS)rsct|ttfr |j|St||Sr )rbrrrdictrrs rrz!CachingEntityRegistry.__getitem__s; fsEl + + 29V$ $##D&11 1rc0t||x||<}|Sr )r)rr*items r __missing__z!CachingEntityRegistry.__missing__s'c222S D rN)rrrrrrrrrsrss2222 rrs)r itertoolsrloggingbaserrrr getLoggerrr%rrrobjectr rrtrrrrurrsrrrrsg!!***k?k?k?k?k?6k?k?k?\ % % % % %< % % %!LNN $$$$$L$$$>b5b5b5b5b5<b5b5b5J6.6.6.6.6.\6.6.6.r     0        2D     r