K idZdZddlZddlmZddlZddlZddlZddlZddl Z ddl m Z ddl m Zddl mZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZe j8ZdZdZdZ ejBZ!Gdde"Z#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,d Z-d!Z.d"Z/d#Z0d$Z1d%Z2d&Z3d'Z4Gd(d)e5Z6d*Z7d+Z8d,Z9d-Z:d.Z;d/Zd2Z?d3Z@d4ZAd5ZBd6ZCd7ZDd8ZEd9ZFd:ZGd;ZHd<ZId=ZJd>ZKd?ZLd@ZMdAZNdBZOdCZPdDZQdEZRdFZSdGZTdHZUdIZVGdJdKeWZXGdLdMeXZYy)Na Contains a metaclass and helper functions used to create protocol message classes from Descriptor objects at runtime. Recall that a metaclass is the "type" of a class. (A class is to a metaclass what an instance is to a class.) In this case, we use the GeneratedProtocolMessageType metaclass to inject all the useful functionality into the classes output by the protocol compiler at compile-time. The upshot of all this is that the real implementation details for ALL pure-Python protocol buffers are *here in this file*. z#robinson@google.com (Will Robinson)N)BytesIO) descriptor)message) text_format)api_implementation) containers)decoder)encoder)enum_type_wrapper)extension_dict)message_listener) type_checkers)well_known_types) wire_formatzgoogle.protobuf.Anygoogle.protobuf.Structgoogle.protobuf.ListValuec0eZdZdZdZfdZfdZxZS)GeneratedProtocolMessageTypea\Metaclass for protocol message classes created at runtime from Descriptors. We add implementations for all methods described in the Message class. We also create properties to allow getting/setting all fields in the protocol message. Finally, we create slots to prevent users from accidentally "setting" nonexistent fields in the protocol message, which then wouldn't get serialized / deserialized properly. The protocol compiler currently uses this metaclass to create protocol message classes at runtime. Clients can also manually create their own classes at runtime, as in this example: mydescriptor = Descriptor(.....) factory = symbol_database.Default() factory.pool.AddDescriptor(mydescriptor) MyProtoClass = message_factory.GetMessageClass(mydescriptor) myproto_instance = MyProtoClass() myproto.foo_field = 23 ... DESCRIPTORcx|tj}t|tr t dt |dd}|r|S|j tjvr!|tj|j fz }t||t||tt|}|j||||}|S)akCustom allocation for runtime-generated class types. We override __new__ because this is apparently the only place where we can meaningfully set __slots__ on the class we're creating(?). (The interplay between metaclasses and slots is not very well-documented). Args: name: Name of the class (ignored, but required by the metaclass protocol). bases: Base classes of the class we're constructing. (Should be message.Message). We ignore this field, but it's required by the metaclass protocol dictionary: The class dictionary of the class we're constructing. dictionary[_DESCRIPTOR_KEY] must contain a Descriptor object describing this protocol message type. Returns: Newly-allocated class. Raises: RuntimeError: Generated code only work with python cpp extension. z\The generated code only work with python cpp extension, but it is using pure python runtime._concrete_classN) r_DESCRIPTOR_KEY isinstancestr RuntimeErrorgetattr full_namerWKTBASES&_AddClassAttributesForNestedExtensions _AddSlotssuper__new__)clsnamebases dictionaryr new_class superclass __class__s m/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/google/protobuf/internal/python_message.pyr"z$GeneratedProtocolMessageType.__new__Vs08HHIJ*c" K LL $5t*>?AAe*:zB j*%3S9J""3eZ@I c0|tj}t|dd}|r||usJd|jzyi|_i|_|j rL|jjr2tj|df|jtj<|jD]}t|||jrNt|j dr8|j j"j%|}|D]}t||||_t)||t+||t-||t/||t1|t3||t5||t7t|} | j9|||y)aHere we perform the majority of our work on the class. We add enum getters, an __init__ method, implementations of all Message methods, and properties for all fields in the protocol type. Args: name: Name of the class (ignored, but required by the metaclass protocol). bases: Base classes of the class we're constructing. (Should be message.Message). We ignore this field, but it's required by the metaclass protocol dictionary: The class dictionary of the class we're constructing. dictionary[_DESCRIPTOR_KEY] must contain a Descriptor object describing this protocol message type. rNzBDuplicate `GeneratedProtocolMessageType` created for descriptor %rpool)rrrr_message_set_decoders_by_tag_fields_by_tag has_options GetOptionsmessage_set_wire_formatr MessageSetItemDecoderMESSAGE_SET_ITEM_TAGfields_AttachFieldHelpers is_extendablehasattrfiler-FindAllExtensionsr_AddEnumValues_AddInitMethod_AddPropertiesForFields_AddPropertiesForExtensions_AddStaticMethods_AddMessageMethods_AddPrivateHelperMethodsr!__init__) r#r$r%r&rexisting_classfield extensionsextr(r)s r*rBz%GeneratedProtocolMessageType.__init__s"8HHIJZ):DAN s "$ N  ! ! #$ " ')C$C77  ' ' 3 Hc&&w'C'CD ""&#u%&GJOOV$D??''99*Ej&#C%&"%J:s#:s#J, C0cz3'Z-3S9JeZ0r+)__name__ __module__ __qualname____doc__rr"rB __classcell__r)s@r*rr;s.!/3j8181r+rc|S)aReturns the name of the public property attribute which clients can use to get and (in some cases) set the value of a protocol message field. Args: proto_field_name: The protocol message field name, exactly as it appears (or would appear) in a .proto file. )proto_field_names r* _PropertyNamerPs 4 r+cgd|d<y)a Adds a __slots__ entry to dictionary, containing the names of all valid attributes for this message type. Args: message_descriptor: A Descriptor instance describing this message type. dictionary: Class dictionary to which we'll add a '__slots__' entry. ) _cached_byte_size_cached_byte_size_dirty_fields_unknown_fields_is_present_in_parent _listener_listener_for_children __weakref___oneofs __slots__NrN)message_descriptorr&s r*r r s(*[r+c|jxry|jjxra|jjjxr;|j t jk(xr|j xr |j SN) is_extensioncontaining_typer0r1r2type_FieldDescriptor TYPE_MESSAGE is_required is_repeatedrDs r*_IsMessageSetExtensionrgs       + +    * * , D D  **(55 5      !r+cl|jtjk(xr|jjSr^)rarbrc message_type _is_map_entryrfs r* _IsMapFieldrks. **(55 5 +    * *,r+cn|jjd}|jtjk(S)Nvalue)rifields_by_namecpp_typerbCPPTYPE_MESSAGE)rD value_types r*_IsMessageMapFieldrr s0!!009*    0 @ @ @@r+ct_fd}|tjjdj r8t jjr|t jdyyy)Nchtjj|}|fj|<yr^)r TagBytesnumberr/)wiretype is_packed tag_bytesr#field_descriptors r* AddFieldByTagz*_AttachFieldHelpers..AddFieldByTags1  !1!8!8(CI%5y$ACy!r+FT) _DefaultValueConstructorForField_default_constructorrFIELD_TYPE_TO_WIRE_TYPErarerIsTypePackableWIRETYPE_LENGTH_DELIMITED)r#rzr{s`` r*r6r6sv*J+'B++,<,A,ABE!!k&@&@' +77> '!r+c:t|dry|j}t|}|j}|r5t j |}t j |t|}nt|r?t j|j}t j|j}n\tj|j|j||}tj|j|j||}||_||_y)N_encoder)r8rerkrxr MapEncoderMapSizerrrrgMessageSetItemEncoderrvMessageSetItemSizerrTYPE_TO_ENCODERra TYPE_TO_SIZER_sizerr)r#rzre is_map_entryrx field_encodersizers r*_MaybeAddEncoderr%s z*  ,,+-.,(()&&'78M   -/0@A CE./112B2I2IJM  ' '(8(?(? @E!112B2G2GHi9M  ' '(8(=(= >i 9E"+r+ctdryjtifd}|dr'tjj r|d_y)N _decoderscj}|tjk(r&jjstj }d}j }r,t}tjt|}n|tjk(r:tjj|jj }nj tj"k(r1t%j&|j|j}n.AddDecoderEsP"''K'111  & & 0 0$//k((4))*:;n(( 78HI m (44 4++  ! !; ,AA++ +-m  " "&6&F&F F#33K@  ! !; ,AACm$33K@  ! !; ,AA++ + -m "/OIr+FT)r8rerkrrrar)r#rzrrrres ` @@@r*_MaybeAddDecoderr=sf {+  ,,+-.,/ /D U[//0@0E0EFt.r+cb|j}|jD]\}}||vsJ|||<yr^)extensions_by_nameitems)rr&rEextension_nameextension_fields r*rrqsB,,*)3)9)9);1%no  ++ +!0J~1r+c|jD]^}t||jtj||j D]#}t||j|j %`y)aSets class-level attributes for all enum fields defined in this message. Also exporting a class-level object that can name enum values. Args: descriptor: Descriptor object for this message type. cls: Class we're constructing for this message type. N) enum_typessetattrr$r EnumTypeWrappervaluesrv)rr#r enum_values r*r;r;xs`((7i C!2!B!B9!MN&&7  c:??J$5$5677r+cjstdjzjj}t j |d|dtr fd}|St j fd}|S)Nz&map_entry set on non-repeated field %skeyrmcptj|jjjSr^)r MessageMaprXri)rrD key_checker value_fields r*MakeMessageMapDefaultz:_GetInitializeDefaultForMap..MakeMessageMapDefaults2  " "  ( (+*B*BK   r+c\tj|jjSr^)r ScalarMaprXri)rrDr value_checkers r*MakePrimitiveMapDefaultz<_GetInitializeDefaultForMap..MakePrimitiveMapDefaults,  ! !  ( (+}   r+)re ValueErrorr$rirnrGetTypeCheckerrr)rDrnrrrrrs` @@@r*rrs    =  %%44.,,^E-BC+w'+ ! !00=M #"r+ctr tSjrjr'jgk7rt djzj tjk(rjfd}|Stjfd}|Sj tjk(rjfd}|Sfd}|S)aReturns a function which returns a default value for a field. Args: field: FieldDescriptor object for this field. The returned function has one argument: message: Message instance containing this field, or a weakref proxy of same. That function in turn returns a default value for this field. The default value may refer back to |message| via a weak reference. z/Repeated field default value not empty list: %scXtj|jjSr^)rRepeatedCompositeFieldContainerrXrirrDs r*MakeRepeatedMessageDefaultzD_DefaultValueConstructorForField..MakeRepeatedMessageDefaults)99  * *E,>,>@ @r+cDtj|jSr^)rRepeatedScalarFieldContainerrX)r type_checkers r*MakeRepeatedScalarDefaultzC_DefaultValueConstructorForField..MakeRepeatedScalarDefaults!66  * *L: :r+ctdsddlm}|jj }|j j t||S|j|S)Nrrmessage_factory) r8google.protobufrGetMessageClassr _SetListenerr_OneofListenerrX)rrresultrDris r*MakeSubMessageDefaultz?_DefaultValueConstructorForField..MakeSubMessageDefaultsq \#4 53'' 5++-f   # # / % (/m--/mr+cjSr^) default_valuers r*MakeScalarDefaultz;_DefaultValueConstructorForField..MakeScalarDefaults   r+) rkrrehas_default_valuerrrorbrprirr)rDrrrrrirs` @@r*r|r|s &u --  5#6#6"#< H      ~~)999''l@('"11%8l:'& ^^'777%%L  !  r+ctjd}t|jdk(r-t |t urt t |d|d|}|jtjd)zCRe-raise the currently-handled TypeError with the field name added.z for field .)sysexc_infolenargsra TypeErrorrwith_traceback) message_name field_nameexcs r*_ReraiseTypeErrorWithFieldNamers` q#]aDI2 CHlJO PC 3<<>!,--r+cDdfd}d|_d|_||_y)zAdds an __init__ method to cls.ct|tr |j|jS|S#t$rt d|j d|dwxYw)aConvert a string or integer enum value to an integer. If the value is a string, it is converted to the enum value in enum_type with the same name. If the value is not a string, it's returned as-is. (No conversion or bounds-checking is done.) z Enum type z: unknown label "")rrvalues_by_namervKeyErrorrr)rrms r*_GetIntegerEnumValuez,_AddInitMethod.._GetIntegerEnumValues_%)''.555 L)   () ))s -&Ac fd}d|_t|dkD|_i|_i|_d|_d|_tj|_ t||_ |jD]\}}t |}|t jd|d|3|j r^|j#|}|j$t&j(k(rt+|rdt-|rG|D]A}||}t/|t0r||j2di|.||j5|Cn|j7|n|D]\} t/| t0r0|j8j:t<k7r|j>di| C|j?} ||| | ^nN|j$t&j@k(r |D cgc]}  |jB| }} |jE|||j|<|j$t&j(k(r|j#|}t/|t0rK|j8j:t<k7r.|j8jFdi|} |j5| n ||||||j|<C|j$t&j@k(r |jB|} tK|||ycc} w#t$rtI j|YywxYw#t$rtI j|YwxYw)Nc Xt|tjr|j|yt|trd|j j tk(rG|jt|dk(rd|vr |j|y|j|yt|dr|j|ytdjj |j t#|j$#|j|jdi|YyxYw)Nrr5_internal_assignzYMessage field {0}.{1} must be initialized with a dict or instance of same class, got {2}.rN)r message_modMessage MergeFromdictrir_StructFullTypeNameClearrupdaterBr8rrformatr$rarG)rDmsgrmr\s r*init_wkt_or_mergez7_AddInitMethod..init..init_wkt_or_merges E;.. / e UD !  **.AA u:?x50 " JJu  **U  3* + U# 77=v"'' U $$8   " IIK CLL !5 !s >D$D)rrNFz'() got an unexpected keyword argument "r)&rRrrSrTrZrUrVmessage_listener_modNullMessageListenerrW _ListenerrXr_GetFieldByNamerr$rer}rorbrprkrrrrrBrrrirradd CPPTYPE_ENUMrextendrrr)selfkwargsrr field_valuerD field_copyr item_valuevalnew_msgnew_valrr\s r*initz_AddInitMethod..inits  8D#&v;?D DLDLD!&D)==?DN"+D/D#)<<>7N K0*=e +00*>? ?     //5 >>-== =  !%($8#(- j$/**S/**8Z8S/++J7 8 ," 7C&$$..2EE %%$..*!%#6 7^^/<< <&13"0E3K3   K (( U >>-== =//5 k4 (    ( (,? ?6E&&66EE'   w ' P eZ =) U >>-:: :,U__kJ+ N $ K 0k7N@3 P *+=+B+BJ O P N ();)@)@* M Ns*K; L* L%L"!L"%MMN)rHrJrB)r\r#rrs` @r*r<r<s' bNH$/$,#,r+ct |j|S#t$rtd|jd|dwxYw)zReturns a field descriptor by field name. Args: message_descriptor: A Descriptor describing all fields in message. field_name: The name of the field to retrieve. Returns: The field descriptor associated with the field name. Protocol message has no "" field.)rnrrr$)r\rs r*rr]sD<  , ,Z 88 < (--z; <<z)_AddPropertiesForFields..us >$+?r+N)r5_AddPropertiesForFieldr7property Extensions)rr#rDs r*r=r=ms@  'e5#&'?@CNr+c4tjdk(sJ|jjdz}t |||j |j r t||y|jtjk(r t||yt||y)a#Adds a public property for a protocol message field. Clients can use this property to get and (in the case of non-repeated scalar fields) directly set the value of a protocol message field. Args: field: A FieldDescriptor for this field. cls: The class we're constructing. _FIELD_NUMBERN) rb MAX_CPPTYPEr$upperrrvre_AddPropertiesForRepeatedFieldrorp*_AddPropertiesForNonRepeatedCompositeField'_AddPropertiesForNonRepeatedScalarField)rDr# constant_names r*r r xsy  % % ++ +**""$6- #}ell+ "5#. ~~)999.uc:+E37r+ceZdZdZdZy)_FieldProperty)rcDtj||||||_y)Ndoc)r rBr)rrgettersetterrs r*rBz_FieldProperty.__init__s  dFF4 DOr+N)rGrHrIr[rBrNr+r*rrs )!r+rc jt}fd}d|_dz|_fd}dz}t ||t |||y)aAdds a public property for a "repeated" protocol message field. Clients can use this property to get the value of the field, which will be either a RepeatedScalarFieldContainer or RepeatedCompositeFieldContainer (see below). Note that when clients add values to these containers, we perform type-checking in the case of repeated scalar fields, and we also set any necessary "has" bits as a side-effect. Args: field: A FieldDescriptor for this field. cls: The class we're constructing. c|jj}|-j|}|jj|}|Sr^rTgetr} setdefaultrrrDs r*rz._AddPropertiesForRepeatedField..getterK,,""5)K..t4kLL++E;?k r+NGetter for %s.c tdz)NzIAssignment not allowed to repeated field "%s" in protocol message object.)AttributeError)r new_valuerOs r*rz._AddPropertiesForRepeatedField..setters <>NO PPr+/Magic attribute generated for "%s" proto field.rr$rPrHrJrr)rDr# property_namerrrrOs` @r*rrs`ZZ 01- &#&66&.P :.getters <<  E= 11r+Nr&cV j|}js2t j |r|j jdn||j <|js|jyy#t$r }tdj||fzd}~wwxYw)NzCannot set %s to %.1024r: %s) CheckValuerrrr IsDefaultScalarValuerTpoprS _Modified)rr)erDrs r* field_setterz=_AddPropertiesForNonRepeatedScalarField..field_settersL)))4i   '">">y"I llud#%dll5  ' ' nn ( L  (EOOY+J J LLLsA?? B(B##B(c:|||jyr^)_UpdateOneofState)rr)rDr5s r*rz7_AddPropertiesForNonRepeatedScalarField..setters4# U#r+zSetter for %s.r*r) r$rPrrrrHrJrrr) rDr#rOr,rrrrr5rs ` @@@r*rrsZZ 01---e4,%%-2&#&66&.$ $F&#&66&. :.getter r%r+Nr&cjjdk(r'||jj|yjjdk(r'||jj |yjjt k(rD||jj |jj|yjjtk(rD||jj |jj|ytdz)Nzgoogle.protobuf.Timestampzgoogle.protobuf.DurationzJAssignment not allowed to composite field "%s" in protocol message object.) rirrT FromDatetime FromTimedeltarrr_ListValueFullTypeNamerr()rr)rDrrOs r*rz:_AddPropertiesForNonRepeatedCompositeField..setter s ##'BB Tl ll5&&y1    % %)C C Tl ll5'' 2    % %)< < Tl ll5! ll5  +    % %)? ? Tl ll5! ll5  +  -/? @ r+r*rr+)rDr#r,rrrrOs` @@r*rrs_ZZ 01- &#&66&., :r>:so,,*)3)9)9);8%no"((*_no-op to keep generated code <=4.23 working with new runtimes.NrN)_s r*RegisterExtensionz,_AddStaticMethods..RegisterExtensionIs r+c8}|j||Sr^)MergeFromString)srr#s r* FromStringz%_AddStaticMethods..FromStringOseG A Nr+) staticmethodrBrF)r#rBrFs` r*r?r?Gs+ ''89# +#.r+c|djrt|dS|djtjk(r|dj Sy)zGiven a (FieldDescriptor, value) tuple from _fields, return true if the value should be included in the list returned by ListFields().rrT)reboolrorbrprVitems r* _IsPresentrLVsK !W Q= Aw+;;; 7 ( (( r+cd}||_y) Helper for _AddMessageMethods().c|jjDcgc]}t|s|}}|jd|Scc}w)Nc |djS)Nr)rvrJs r*r z:_AddListFieldsMethod..ListFields..gstAw~~r+)r)rTrrLsort)rrK all_fieldss r* ListFieldsz(_AddListFieldsMethod..ListFieldsesD#'<<#5#5#7L4:d;K$LJLOO5O6 Ms A A N)rS)r\r#rSs r*_AddListFieldsMethodrTbs #.r+cijD]+}|jr|js||j<-jD]}||j<fd|_y)rNc |}t|tj r! ||j |jS|jtjk(r-|jj|}|duxr |jS||jvS#t$r"}tdjd|d|d}~wwxYw#t$rYywxYw)Nrz has no non-repeated field "z3" nor has presence is not available for this field.F)rrrrdescriptor_modOneofDescriptorrZr$rorbrprTr"rV)rrrDrrmHasFieldhassable_fieldsr\s r*rYz$_AddHasFieldMethod..HasField}sOj)e %778dll516677 +;; ;   'D @U%@%@@ $$ O -77E FKNOOs(BC  C$CC CCN)r5rerr$oneofsrY)r\r#rDoneofrYrZs` @@r*_AddHasFieldMethodr]msx/!(((e    "'OEJJ ("(((e"'OEJJ(%(#,r+cfd}||_y)rNc : j|}||j vrt|j |dr|j |j|j |=|jj|jd|ur|j|j=|jy#t$r^ j|}||jvr|j|}nYyn)#t$rt dj d|dwxYwYwxYw)NrrrInvalidateIterators) rnroneofs_by_namerZrr$rTr8r`r"rr3)rrrDr\s r* ClearFieldz(_AddClearFieldMethod..ClearFields @ // ;e   e$&; < U//1 ,,u    %00$ 75 @ LL// 0  NN9  @@"11*= DLL ,,u%%  @,11:?@ @@  @s)B33 D=-C-,D-&DDDN)rb)r\r#rbs` r*_AddClearFieldMethodrcsB#.r+cd}||_y)rNctj||||jvr |j|=|jyr^)r _VerifyExtensionHandlerTr3)rrzs r*ClearExtensionz0_AddClearExtensionMethod..ClearExtensions8))$0@A4<<' ,,' (NNr+N)rg)r#rgs r*_AddClearExtensionMethodrhs&#r+cd}||_y)rNc&tj|||jrtd|jz|j t jk(r-|jj|}|duxr |jS||jvS)Nz"%s" is repeated.) r rfrerrrorbrprTr"rV)rrzrms r* HasExtensionz,_AddHasExtensionMethod..HasExtensions))$0@A## (+;+E+EE FF  $4$D$DDll/0e $  >5#>#>>  --r+N)rk)r#rks r*_AddHasExtensionMethodrls ."#r+c&ddlm}|j}|j}|sy|j dd}|j j |}|yddlm}|j|}|}|j|j|S)atUnpacks Any message and returns the unpacked message. This internal method is different from public Any Unpack method which takes the target message as argument. _InternalUnpackAny method does not have target message type and need to find the message type in descriptor pool. Args: msg: An Any message to be unpacked. Returns: The unpacked message. r)symbol_databaseN/r) rrnDefaulttype_urlsplitr-FindMessageTypeByNamerrParseFromStringrm) rrnfactoryrr type_namerr message_classrs r*_InternalUnpackAnyrys".  # # %' \\(  nnS!"%)||11)<* .!11*=- O' #))$ .r+cd}||_y)rNc|jjtk(r!t|tr|j |S|jjt k(r!t|tr|j |St|tjr|j|jk7rtS||ury|jjtk(rt|}t|}|r|r||k(S|j|jk(syt |j}|jt |j}|j||k(S)NTF)rrr=rlist_internal_comparerrrrNotImplemented_AnyFullTypeNameryrSrUrQ)rotherany_aany_bunknown_fieldsother_unknown_fieldss r*__eq__z _AddEqualsMethod..__eq__s1   $::z t@ # #E **   $77J t= # #E ** uk11 2 DOO+  u}    $44 &e 'e 5~ ??  0 0 2 2 $../N 5 56 1 11r+N)r)r\r#rs r*_AddEqualsMethodrs 2D#*r+cd}||_y)rNc,tj|Sr^rMessageToStringr s r*__str__z_AddStrMethod..__str__(  & &t ,,r+N)r)r\r#rs r* _AddStrMethodr&s-#+r+cd}||_y)rNc,tj|Sr^rr s r*__repr__z _AddReprMethod..__repr__/rr+N)r)r\r#rs r*_AddReprMethodr-s-#,r+cd}||_y)rNcNtj|djdS)NT)as_utf8zutf-8)rrdecoder s r* __unicode__z&_AddUnicodeMethod..__unicode__7s  & &tT : A A' JJr+N)r)unused_message_descriptorr#rs r*_AddUnicodeMethodr4sK#/r+c|jdk(r d}||_y|jdk(r d}||_yd}||_y)Nrc||jvSr^)r5)rrs r* __contains__z(_AddContainsMethod..__contains__?s DKK r+rc&||jvSr^)r)rrms r*rz(_AddContainsMethod..__contains__Bs djjl ""r+c$|j|Sr^)rY)rrDs r*rz(_AddContainsMethod..__contains__Es ]]5 !!r+)rr)r\r#rs r*_AddContainsMethodr<sO!!%== "###'BB# "#""#r+c tj|}|||S#t$rtjd|zwxYw)a Returns the number of bytes needed to serialize a non-repeated element. The returned byte count includes space for tag information and any other additional space associated with serializing value. Args: value: Value we're serializing. field_number: Field number of this value. (Since the field number is stored as part of a varint-encoded tag, this has an impact on the total bytes required to serialize the value). field_type: The type of the field. One of the TYPE_* constants within FieldDescriptor. zUnrecognized field type: %d)rTYPE_TO_BYTE_SIZE_FNrr EncodeError)rm field_number field_typefns r*_BytesForNonRepeatedElementrKsMN  + +J 7B lE "" N  ! !"?*"L MMNs "Acfd}|_y)rNcV|js |jSd}|j}|jrp|jd}t ||j |j}|jd}t |||j |jz }nf|jD]%\}}t |||j |z }'|jD]\}}|t|t|zz }!||_d|_d|j_ |S)NrrrmF)rSrRrrjrnrrrrmrSrUrrXdirty) rsizer key_fieldrrzrry value_bytesr#s r*ByteSizez$_AddByteSizeMethod..ByteSizebs&  ' '  # ## DJ++E2isI&   dhh 'd--g6ksK( k  ,,d+/??+<5 ' K./  '' 445%)$8$82 )[ I[!1112"D#(D (-D% Kr+N)r)r\r#rs ` r*_AddByteSizeMethodr_s4#,r+cd}||_y)rNc |jsLtjd|jjddj |j |jdi|S)NzMessage z is missing required fields: ,rN) IsInitializedrrrrjoinFindInitializationErrorsSerializePartialToString)rrs r*SerializeToStringz6_AddSerializeToStringMethod..SerializeToStringsb      # # // # #SXXd.K.K.M%N P QQ )4 ( ( 26 22r+N)r)r\r#rs r*_AddSerializeToStringMethodrs3,#r+c4d}|_dfd }|_y)rNcpt}|j|jfi||jSr^)r_InternalSerializewritegetvalue)rrouts r*rzD_AddSerializePartialToStringMethod..SerializePartialToStrings. )CDCII00 <<>r+Nc|tj}n t|}|j}|jrq|j d}t ||j||j||j d}t ||j||j|y|jD]$\}}t ||j|||&|jD]\}} |||| y)Nrrm) r)IsPythonDefaultSerializationDeterministicrIrrjrnrrrrmrSrU) r write_bytes deterministicrrrrzrryrr#s r*InternalSerializez=_AddSerializePartialToStringMethod..InternalSerializes  F F H=)mJ++E2isI&dhh >--g6ksK(; MB+/??+<K ' K./!!+{MJK%)$8$8! )[IK !r+r^)rr)r\r#rrs ` r*"_AddSerializePartialToStringMethodrs!":#!.-#r+cld}|_jjdfd }|_y)rNc2t|}t|} |j|d||k7rtjd |S#t t f$rtjdtj$r}tj|d}~wwxYw)NrzUnexpected end-group tag.zTruncated message.) memoryviewr_InternalParser DecodeError IndexErrorrstructerror)r serializedlengthr4s r*rDz2_AddMergeFromStringMethod..MergeFromStringsJ'J _F '  ZF 3v =%%&ABB > M  ":  # #$8 99 <<'  # #A &&'s+A6B<BBct|tsJ|j|j}||k7rEt j ||\}}j |d\}} |r ||||||}Cj |d\} } | |jsg|_t j|\} } | dk(rtjdt j|||| | \} }|dk(r|S|jj|||t|z|jf|}nEt| | j | }|||||||}| j"r|j%| ||k7rE|S)a6Create a message from serialized bytes. Args: self: Message, instance of the proto message object. buffer: memoryview of the serialized data. pos: int, position to start in the serialized data. end: int, end position of the serialized data. Returns: Message object. )NNrzField number 0 is illegal.rp)rrr3rTr ReadTagr"rU DecodeTagrr_DecodeUnknownFieldappendrtobytesrrrr7)rbufferposend current_depth field_dictrynew_posr field_desrxr wire_typedatar# fields_by_tagmessage_set_decoders_by_tags r* InternalParsez0_AddMergeFromStringMethod..InternalParses fj )) )NNJ *$__VS9y'! i 1 ''(DE E!55 GS,  w b=* ## sS^3g>FFH I i(!++I6  GS$ M   % %   +? *@ Jr+N)r)rDr/r.r)r\r#rDrrrs ` @@r*_AddMergeFromStringMethodrs9 (#$$- # @ @1f%#r+c|jDcgc]}|jr|c}dfd }||_fd}||_ycc}w)z[Adds the IsInitialized and FindInitializationError methods to the protocol message class.NcD]j}||jvs8|jtjk(s/|j|jrI||j |j yt|jjD]\}}|jtjk(s$|jrS|jjrG|D]6}|jr||j |j y|js|jr||j |j yy)aChecks if all required fields of a message are set. Args: errors: A list which, if provided, will be populated with the field paths of all missing required fields. Returns: True iff the specified message has all required fields set. FT) rTrorbrprVrrr|rrerirjr)rerrorsrDrmelementrequired_fieldss r*rz._AddIsInitializedMethod..IsInitializeds*! t|| # >>-== =||E"88   --557 8 T\\//12  u +;; ;     ..  g((*# d;;=>    ( (1D1D1F   MM$779 :  r+cg} D]9}|j|jr|j|j;|jD]!\}}|jt j k(s%|jrd|jz}n |j}t|rGt|r;|D]5}||}|d|d}|j}||D cgc]} || z c} z }7|jrLtt|D]4} || }d|| fz}|j}||D cgc]} || z c} z }6|dz}|j}||D cgc]} || z c} z }$|Scc} wcc} wcc} w)zFinds required fields which are not initialized. Returns: A list of strings. Each string is a path to an uninitialized field from the top-level message, e.g. "foo.bar[5].baz". z(%s)[z].z%s[%d].r)rYr$rrSrorbrpr_rrkrrrreranger) rrrDrmr$rrprefix sub_errorsrirs r*rz9_AddIsInitializedMethod..FindInitializationErrors)sF " ]]5:: & ejj!")= u +;; ;   %//)$$ u   & Ac g$(#.f";;=jZ@E%@@f  A    U$ ?aAhG$*F 99;J :>%v~> >F  ? #:&557* <Ve^< <&5=8 MA?=s E9 5 E> # Fr^)r5rdrr)r\r#rDrrrs @r*_AddIsInitializedMethodrsQ);(A(A1u#//1/$L$#*X":#o1sAcd|j}t|d|j}|dvr|S|dz|zS)NrI)Nbuiltins __builtin__r)rHrrG)klassmoduler$s r*_FullyQualifiedClassNamerXs<   &  7$ 00 K # r+cBtjfd}|_y)Nc"t|s.tdtdt|jd||usJ|j |j }|j j D]\}}|jr;|j|}||j|}|||<|j|M|jk(rH|jsi|j|}||j|}|||<|j|||j |<|js|j||jr9|jsg|_|jj!|jyy)NzBParameter to MergeFrom() must be instance of same class: expected z got r)rrrr)r3rTrrer"r}rrorVrr7rUr)rrr5rDrmrrpr#s r*rz&_AddMergeFromMethod..MergeFromcsk c3  #;C#@#;CMM#J L MM d??NN \\F ))+( u   jj'  2248+%&-e$ >>_ ,  & & 5)+  44T:K'F5M    &# U  ! !   ''(*   ! !! !!#"5"56r+)rbrpr)r#rrps` @r*_AddMergeFromMethodr`s$44/$7L#-r+cfd}||_y)Nc j|}|jj |d}|'|j |j r |j Sy#t$rtd|zwxYw)zDReturns the name of the currently set field inside a oneof, or None.z)Protocol message has no oneof "%s" field.N)rarrrZr"rYr$)r oneof_namerD nested_fieldr\s r* WhichOneofz(_AddWhichOneofMethod..WhichOneofsD // ;e <<##E40LDMM,2C2C$D     D  5 B DDDs AA0)r)r\r#rs` r*_AddWhichOneofMethodrs #.r+cNi|_d|_i|_|jy)NrN)rTrUrZr3r s r*_Clearrs"$,$$,..r+ctd)NzbPlease use the add-on feaure unknown_fields.UnknownFieldSet(message) in unknown_fields.py instead.)NotImplementedErrorr s r*_UnknownFieldsrs9 ::r+cJg|_|jD]\}}|jtjk(s$t |r't |s;|D]}||jV|jr|D]}|jz|jyr^) rUrSrorbrprkrrDiscardUnknownFieldsre)rrDrmr sub_messages r*_DiscardUnknownFieldsrs$oo' %leU ~~)999 U  e $ .c #J + + - .     -K  * * , - ""$ %r+cJ|tj|_y||_yr^)rrrW)rlisteners r*rrs )==?DNDNr+ct||t||t|||jrt |t |t ||t||t||t||t||t||t||t||t||t||t!|t#||t$|_t(|_t,|_y)z3Adds implementations of all Message methods to cls.N)rTr]rcr7rhrlrrrrrrrrrrrrrrrrr)r\r#s r*r@r@s)3/'-)3/%%S!3%s+"C(#S)&,'-'-0#6$%7=.4,c2c)3/#)2#!#r+c:d}d}||_||_||_y)z5Adds implementation of private helper methods to cls.c|js:d|_d|j_d|_|jj yy)zwSets the _cached_byte_size_dirty bit to true, and propagates this to our listener iff this was a state change. TN)rSrXrrVrWModifiedr s r*r z*_AddPrivateHelperMethods..Modifieds@  ' '%)d"*.d!!'#'d  nn (r+c|jj|j|}||ur'|j|=||j|j<yy)zSets field as the active field in its containing oneof. Will also delete currently active field in the oneof, if it is different from the argument. Does not mark the message as modified. N)rZr#rrT)rrD other_fields r*r7z3_AddPrivateHelperMethods.._UpdateOneofStatesM ,,))%*@*@%HK% ,,{ #-2dll5))* r+N)r3 SetInParentr7)r\r#r r7s r*rArAs$   3#-#/+#r+ceZdZdZdZdZy)ra0MessageListener implementation that a parent message registers with its child message. In order to support semantics like: foo.bar.baz.moo = 23 assert foo.HasField('bar') ...child objects must have back references to their parents. This helper class is at the heart of this support. ct|tjr||_d|_ytj||_d|_y)zArgs: parent_message: The message whose _Modified() method we should call when we receive Modified() messages. FN)rweakref ProxyType_parent_message_weakrefproxyr)rparent_messages r*rBz_Listener.__init__ sA.'"3"34%3d"DJ &-]]>%Bd" DJr+cr|jry |jjy#t$rYywxYwr^)rrr3ReferenceErrorr s r*r z_Listener.Modified s7 zz   "",,.    s * 66N)rGrHrIrJrBr rNr+r*rrs &  r+rc,eZdZdZfdZfdZxZS)rzCSpecial listener implementation for setting composite oneof fields.c:tt| |||_y)zArgs: parent_message: The message whose _Modified() method we should call when we receive Modified() messages. field: The descriptor of the field being set in the parent message. N)r!rrB_field)rrrDr)s r*rBz_OneofListener.__init__0s  .$(8DKr+c |jj|jtt|y#t $rYywxYw)zEAlso updates the state of the containing oneof in the parent message.N)rr7rr!rr r)rr)s r*r z_OneofListener.Modified9s?  ""44T[[A ND*,    s7; AA)rGrHrIrJrBr rKrLs@r*rr-sK  r+r)ZrJ __author__datetimeiormathrrwarningsrrrrWrrrgoogle.protobuf.internalrrr r r r r rrrrFieldDescriptorrbrrr=r rarrPr rgrkrrr6rrrr;rr|rr<rr=r r rrrrr>r?rLrTr]rcrhrlryrrrrrrrrrrrrrrrrrrr@rAobjectrrrNr+r*r"s 3  82'7/,,63M250!11(.4..H14H1f:(&!, A?*,01/h1 7#,7t.xv < A82!X!)NX5Np:Nz   , $N#L & "(V$N  "N(@ , -FH%V[:|)X$: %"4,D+ + \ Y r+