ɺhrdZdZddlmZddlZddlZddlZddlmZddlm Z ddlm Z ddlm Z dd lm Z dd lm Z dd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZejZdZe jZGddeZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)d Z*d!Z+d"Z,d#Z-Gd$d%e.Z/d&Z0d'Z1d(Z2d)Z3d*Z4d+Z5d,Z6d-Z7d.Z8d/Z9d0Z:d1Z;d2Zd5Z?d6Z@d7ZAd8ZBd9ZCd:ZDd;ZEd<ZFd=ZGd>ZHd?ZId@ZJdAZKdBZLdCZMdDZNGdEdFeOZPGdGdHePZQdS)Ia 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))BytesION)api_implementation) containers)decoder)encoder)enum_type_wrapper)extension_dict)message_listener) type_checkers)well_known_types) wire_format) descriptor)message) text_formatzgoogle.protobuf.Anyc0eZdZdZdZfdZfdZxZS)GeneratedProtocolMessageTypeaQMetaclass 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 = factory.GetPrototype(mydescriptor) myproto_instance = MyProtoClass() myproto.foo_field = 23 ... DESCRIPTORc|tj}t|trt dt |dd}|r|S|jtjvr|tj|jfz }t||t||tt|}| ||||}|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_namer WKTBASES&_AddClassAttributesForNestedExtensions _AddSlotssuper__new__)clsnamebases dictionaryr new_class superclass __class__s /builddir/build/BUILD/imunify360-venv-2.5.2/opt/imunify360/venv/lib64/python3.11/site-packages/google/protobuf/internal/python_message.pyr z$GeneratedProtocolMessageType.__new__hs08HIJ*c""L K L LL $5t<?AAe*:zBBB j*%%%3S99J""3eZ@@I c|tj}t|dd}|r||usJd|jzdSi|_|jrA|jr(tj |df|jtj <|j D]}t||||_ t||t||t!||t#||t%|t'||t)||t+t|}||||dS)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 %r)rrrr_decoders_by_tag has_options GetOptionsmessage_set_wire_formatrMessageSetItemDecoderMESSAGE_SET_ITEM_TAGfields_AttachFieldHelpersr_AddEnumValues_AddInitMethod_AddPropertiesForFields_AddPropertiesForExtensions_AddStaticMethods_AddMessageMethods_AddPrivateHelperMethodsr__init__) r!r"r#r$rexisting_classfieldr&r's r(r:z%GeneratedProtocolMessageType.__init__sv"8HIJZ):DAAN s " " " N  ! ## " " fC;7;  ' 3 3T<;c778"&&#u%%%%!$J:s###:s###J,,, C000cz3'''Z---3S99JeZ00000r))__name__ __module__ __qualname____doc__rr r: __classcell__r's@r(rrMsc.!/33333j010101010101010101r)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( _PropertyNamerFs 4 r)cgd|d<dS)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_unknown_field_set_is_present_in_parent _listener_listener_for_children __weakref___oneofs __slots__NrD)message_descriptorr$s r(rrs ( ( (*[r)c|joS|jjoG|jjo)|jt jko|jt j kSN) is_extensioncontaining_typer,r-r.type_FieldDescriptor TYPE_MESSAGElabelLABEL_OPTIONALr<s r(_IsMessageSetExtensionr^ s_   9   + 9   * * , , D 9 *(5 5 9 +)8 8 :r)c|jtjko)|jjo|jjSrU)rXrYrZ message_typer,r- map_entryr]s r( _IsMapFieldrbs= *(5 5 4   ( 4   ' ' ) ) 35r)cP|jjd}|jtjkS)Nvalue)r`fields_by_namecpp_typerYCPPTYPE_MESSAGE)r< value_types r(_IsMessageMapFieldris$!09*   0 @ @@r)cjtjktj}r7t j}t jt}ntr3t j j }t j j }nLtjjj |}tjjj |}|_|_t'_fd}|tjjdr1t-jjr|t,jddSdSdS)Nctjj|}j}|tjkrjjs tj}d}j } r3t}tj t|}n|tjkr*tjj |jj }nmjtjkr)t)j|j |j}n/t)j|j |jj }||fj|<dSrU)rTagBytesnumberrXrY TYPE_ENUM enum_type is_closed TYPE_INT32containing_oneofrir MapDecoder_GetInitializeDefaultForMap TYPE_STRING StringDecoder_default_constructor has_presencerfrgr TYPE_TO_DECODERr+) wiretype is_packed tag_bytes decode_typeoneof_descriptoris_message_map field_decoderr!field_descriptor is_map_entry is_repeateds r( AddDecoderz'_AttachFieldHelpers..AddDecoder3sj !1!8(CCI"'K'111  & 0 2$/k(4)-)*:;;n( 78HII mm (4 4 4+  !; ,A+ +--mm  "&6&F F F#3K@  !; ,ACCmm$3K@  !; ,A+ + --m (56F&GC###r)FT)r[rYLABEL_REPEATEDrbr{r MapEncoderMapSizerrir^MessageSetItemEncoderrmMessageSetItemSizerr TYPE_TO_ENCODERrX TYPE_TO_SIZER_encoder_sizer _DefaultValueConstructorForFieldrwFIELD_TYPE_TO_WIRE_TYPEr IsTypePackableWIRETYPE_LENGTH_DELIMITED)r!rr{ field_encodersizerrrrs`` @@r(r2r2s!'+;+JJ+-..,() 9&'788M  -/0@AA C CEE.//912B2IJJM  '(8(? @ @EE!12B2GHi99M  '(8(= >i 9 9E,!*J++'!H!H!H!H!H!H!H!HF *] 23C3H I <[/0@0EFF<J{4d;;;;;<<<.MakeMessageMapDefault~s+  "  (+*BK  r)cFtj|jjSrU)r ScalarMaprOr`)rr<r value_checkers r(MakePrimitiveMapDefaultz<_GetInitializeDefaultForMap..MakePrimitiveMapDefaults(  !  (+}  r)) r[rYr ValueErrorr"r`rer GetTypeCheckerri)r<rerrrrrs` @@@r(rtrtus [$333 =   %4.,^E-BCC+w'+ # ! !0==M #"r)ctrtSjtjkrgjr"jgkrtdjzjtj krj fd}|Stj fd}|Sjtj krj fd}|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: %scBtj|jjSrU)rRepeatedCompositeFieldContainerrOr`rr<s r(MakeRepeatedMessageDefaultzD_DefaultValueConstructorForField..MakeRepeatedMessageDefaults&9  *E,>@@ @r)c8tj|jSrU)rRepeatedScalarFieldContainerrO)r type_checkers r(MakeRepeatedScalarDefaultzC_DefaultValueConstructorForField..MakeRepeatedScalarDefaults 6  *L:: :r)ctddsJdjdjd}|jt |n|j|S)Nrz-Uninitialized concrete class found for field z (message type ))rrr _SetListenerrr_OneofListenerrO)rresultr<r`s r(MakeSubMessageDefaultz?_DefaultValueConstructorForField..MakeSubMessageDefaults \#4d ; ;777 ___l444 677 ;++--f   # / % ( ( (-///mr)cjSrU) default_valuers r(MakeScalarDefaultz;_DefaultValueConstructorForField..MakeScalarDefaults  r)) rbrtr[rYrhas_default_valuerrrfrgr`r r)r<rrrrr`rs` @@r(rrs@. &u - -- [$333  5#6"#<#< H      ~)999'l@@@@@('"1%88l:::::'& ^'777%L       !  r)c0tjd}t|jdkr:t |t ur$t t |d|d|}|tjd)zCRe-raise the currently-handled TypeError with the field name added.z for field .)sysexc_infolenargsrX TypeErrorrwith_traceback) message_name field_nameexcs r(_ReraiseTypeErrorWithFieldNamersz q#]]aDII22 CHHHHlllJJO P PC 3<>>!,---r)cFdfd}d|_d|_||_dS)zAdds an __init__ method to cls.ct|tr< |j|jS#t$rt d|jd|dwxYw|S)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_namermKeyErrorrr)rords r(_GetIntegerEnumValuez,_AddInitMethod.._GetIntegerEnumValuesy%))'.55 )))j    ()) )) Ls )&Acd|_t|dk|_i|_i|_d|_d|_d|_tj |_ t||_ | D]^\}}t |t jd|d|5jt$jkr|}jt$jkrt/rLt1r'|D]#}||||$n||n|D]L}t7|t8r|jdi|%||Mn9jt$jkr fd|D}||||j<ejt$jkr|}|}t7|t8rj j!di|} ||n%#t$rtE j|YnwxYw||j<jt$jkr j#|} tI|||:#t$rtE j|Y\wxYwdS)NrrDFz'() got an unexpected keyword argument "rc2g|]}j|SrD)ro).0valrr<s r( z0_AddInitMethod..init.. s8333"0/EE333r))%rHrrIrJrQrKrLrMmessage_listener_modNullMessageListenerrN _ListenerrOr_GetFieldByNamerr"r[rYrrwrfrgrbri MergeFromupdaterdictadd CPPTYPE_ENUMextendr`rrror) selfkwargsr field_valuecopyrrnew_valr<rrSs @r(initz_AddInitMethod..initshD#&v;;?D DLDLD#D!&D)=??DN"+D//D#)<<>>-N-N K0*==e +000***>?? ?   (7 7 7))$// >-= = =    *!%(( '$66#S ##K$455556kk+&&&&" * *C&&*3 $$S))))  * ^/< < <33333&1333K ++k " " "" U >-= = =))$// k4 ( ( F6E&6EEEE' N .. ! ! ! ! N N N ();)@* M M M M M N" U >-: : :,,U_kJJ+ N $ K 0 0 0 0 N N N ();)@* M M M M M NY-N-Ns$>II65I6,J??K"!K"N)r>r@r:)rSr!rrs` @r(r4r4sS   >N>N>N>N>N>N@$/$,#,,,r)cp |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.)rerrr")rSrs r(rr's[<  ,Z 88 <<< *(---zzz; < <<z)_AddPropertiesForFields..?s>$+?+?r)N)r1_AddPropertiesForField is_extendableproperty Extensions)rr!r<s r(r5r57sX ''e5#&&&&A??@@CNNNAAr)cJtjdksJ|jdz}t |||j|jtjkrt||dS|j tj krt||dSt||dS)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) rY MAX_CPPTYPEr"upperrrmr[r_AddPropertiesForRepeatedFieldrfrg*_AddPropertiesForNonRepeatedCompositeField'_AddPropertiesForNonRepeatedScalarField)r<r! constant_names r(rrBs  % + + + +*""$$6- #}el+++ [$333"5#..... ~)999.uc:::::+E377777r)ceZdZdZdZdS)_FieldProperty)rcPt||||||_dS)Ndoc)rr:r)rrgettersetterrs r(r:z_FieldProperty.__init__^s* dFF444 DOOOr)N)r=r>r?rRr:rDr)r(rr[s()!!!!!r)rc jt}fd}d|_dz|_fd}dz}t ||t |||dS)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|j}|0|}|j|}|SrUrJgetrw setdefaultrrr<s r(rz._AddPropertiesForRepeatedField..gettertP,""5))K..t44kL++E;??k r)NGetter for %s.c(tdz)NzIAssignment not allowed to repeated field "%s" in protocol message object.AttributeErrorr new_valuerEs r(rz._AddPropertiesForRepeatedField..setter& <>NO P PPr)/Magic attribute generated for "%s" proto field.rr"rFr>r@rrr<r! property_namerrrrEs` @r(rrcsZ 011-     &#&66&.PPPPP :.getters <  E= 1 11r)Nrc& |}n,#t$r}tdj||fzd}~wwxYwjs|s|jdn ||j<|js|dSdS)NzCannot set %s to %.1024r: %s) CheckValuerrrxrJpoprI _Modified)rrer<rs r( field_setterz=_AddPropertiesForNonRepeatedScalarField..field_settersL)))44ii LLL  (EOY+J J L LLL  &i& lud####%dl5  ' nns A=AcJ|||dSrU)_UpdateOneofState)rrr<r s r(rz7_AddPropertiesForNonRepeatedScalarField..setters/l4### U#####r)zSetter for %s.rr) r"rFr rrr>r@rrrr) r<r!rErrrrrr rs ` @@@r(rrs Z 011--e44,%-222222&#&66&.$ $$$$$$$F&#&66&. :.getterr r)Nrc(tdz)NzJAssignment not allowed to composite field "%s" in protocol message object.rrs r(rz:_AddPropertiesForNonRepeatedCompositeField..setterrr)rrrrs` @r(rrsZ 011-     &#&66&.PPPPP :.RegisterExtensionsD'*~$N445EFFF-.....r)cF}|||SrU)MergeFromString)srr!s r( FromStringz%_AddStaticMethods..FromString s'ceeG A Nr)) staticmethodr.r2)r!r.r2s` r(r7r7s]///// ''899# ++#...r)c|djtjkrt|dS|djtjkr |djSdS)zGiven a (FieldDescriptor, value) tuple from _fields, return true if the value should be included in the list returned by ListFields().rrT)r[rYrboolrfrgrMitems r( _IsPresentr8sQ !W]&555 Q== Aw+;;; 7 (( 4r)cd}||_dS) Helper for _AddMessageMethods().czd|jD}|d|S)Nc0g|]}t||SrD)r8)rr7s r(rz<_AddListFieldsMethod..ListFields..#s%LLL4:d;K;KL$LLLr)c|djS)Nr)rmr6s r(rz:_AddListFieldsMethod..ListFields..$s tAw~r))r)rJrsort)r all_fieldss r( ListFieldsz(_AddListFieldsMethod..ListFields"sALL4<#5#5#7#7LLLJOO55O666 r)N)r@)rSr!r@s r(_AddListFieldsMethodrAs #...r)cijD]*}|jtjkr|js ||j<+jD] }||j< fd|_dS)r:c |}n.#t$r!}tdjd|d|d}~wwxYwt|tjr. ||j|jS#t$rYdSwxYw|jtj kr%|j |}|duo|j S||j vS)Nrz has no non-repeated field "z3" nor has presence is not available for this field.F)rrrrdescriptor_modOneofDescriptorrQr"rfrYrgrJr rM)rrr<rrdHasFieldhassable_fieldsrSs r(rFz$_AddHasFieldMethod..HasField:s Oj)ee OOO J-777E F FKNOO %788 %xdl516777 uu +; ; ;   ''D @U%@@ $$s" 727A11 A?>A?N)r1r[rYrrxr"oneofsrF)rSr!r<oneofrFrGs` @@r(_AddHasFieldMethodrJ*s/!(((e {&555  "'OEJ"(((e"'OEJ%%%%%%%(#,,,r)c fd}||_dS)r:c  j|}nb#t$rU j|}||jvr|j|}nYdSn)#t$rt djd|dwxYwYnwxYw||jvrqt|j|dr|j||j|=|j |j d|ur |j|j =| dS)NrrrInvalidateIterators) reroneofs_by_namerQrr"rJhasattrrMr rrr)rrr<rSs r( ClearFieldz(_AddClearFieldMethod..ClearFieldSs\ @ / ;ee  @ @ @@"1*= DL ,u%%% && @@@j,111:::?@@ @@ % @   e$&; < <2 U//111 ,u    %0$ 7 75 @ @ L/ 0  NNs&  A0$AA0&A**A0/A0N)rP)rSr!rPs` r(_AddClearFieldMethodrQQs*B#...r)cd}||_dS)r:cztj||||jvr|j|=|dSrU)r _VerifyExtensionHandlerJr)rrs r(ClearExtensionz0_AddClearExtensionMethod..ClearExtensionysF)$0@AAA4<'' ,' (NNr)N)rU)r!rUs r(_AddClearExtensionMethodrVws!&#r)cd}||_dS)r:c tj|||jtjkrt d|jz|jtjkr%|j |}|duo|j S||j vS)Nz"%s" is repeated.) r rTr[rYrrrrfrgrJr rM)rrrds r( HasExtensionz,_AddHasExtensionMethod..HasExtensions)$0@AAA!1!@@@ (+;+EE F FF $4$DDDl/00e $  >5#>>  --r)N)rY)r!rYs r(_AddHasExtensionMethodrZs! . . ."#r)c4ddlm}|}|j}|sdS|dd}|j|}|dS||}|}||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/) google.protobufr\Defaulttype_urlsplitr(FindMessageTypeByName GetPrototypeParseFromStringrd)msgr\factoryra type_namer message_classrs r(_InternalUnpackAnyrjs".-----  # # % %' \(  4nnS!!"%)|11)<<* 4&&z22- MOO' #)$$$ .r)cd}||_dS)r:ct|tjr|j|jkrdS||urdS|jjt kr(t |}t |}|r|r||kS||ksdSt|j }| t|j }| ||kS)NFT) r message_modMessagerr_AnyFullTypeNamerjr@listrKr>)rotherany_aany_bunknown_fieldsother_unknown_fieldss r(__eq__z _AddEqualsMethod..__eq__s uk1 2 2 DO++ U u}} T  $444 &&e ''e 5~ ??   0 0 2 2 2 2 U$.//N 566 1 11r)N)rv)rSr!rvs r(_AddEqualsMethodrws2222#***r)cd}||_dS)r:c*tj|SrUrMessageToStringrs r(__str__z_AddStrMethod..__str__  &t , ,,r)N)r|)rSr!r|s r( _AddStrMethodr~s---#+++r)cd}||_dS)r:c*tj|SrUrzrs r(__repr__z _AddReprMethod..__repr__r}r)N)r)rSr!rs r(_AddReprMethodrs---#,,,r)cd}||_dS)r:cTtj|ddS)NT)as_utf8zutf-8)rr{decoders r( __unicode__z&_AddUnicodeMethod..__unicode__s&  &tT : : : A A' J JJr)N)r)unused_message_descriptorr!rs r(_AddUnicodeMethodrsKKK#///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)r TYPE_TO_BYTE_SIZE_FNrrm EncodeError)rd field_number field_typefns r(_BytesForNonRepeatedElementrs]N  +J 7B 2lE " "" NNN  !"?*"L M MMNs  "Acd}||_dS)r:c|js|jSd}|j}|jrN|jd|j}||jd|jz }na| D]\}}|||z }|j D]'\}}|t|t|zz }(||_d|_d|j _ |S)NrrrdF)rIrHrr-rarerrrdr@rKrrOdirty)rsizerrrr| value_bytess r(ByteSizez$_AddByteSizeMethod..ByteSizes   '$  ## DJ(2  &u - 4 4TX > >d j'077 CCCdd+/??+<+<55 ' K  '' 444$($822 )[ I[!1!111!D#(D (-D% Kr)N)r)rSr!rs r(_AddByteSizeMethodrs*#,,,r)cd}||_dS)r:c |sItjd|jjdd||jdi|S)NzMessage z is missing required fields: ,rD) IsInitializedrmrrrjoinFindInitializationErrorsSerializePartialToString)rrs r(SerializeToStringz6_AddSerializeToStringMethod..SerializeToStrings~     Q  # # / # # #SXXd.K.K.M.M%N%N%N P Q QQ )4 ( 2 26 2 22r)N)r)rSr!rs r(_AddSerializeToStringMethodrs!333,#r)c0d}||_dd}||_dS)r:clt}|j|jfi||SrU)r_InternalSerializewritegetvalue)rrouts r(rzD_AddSerializePartialToStringMethod..SerializePartialToString,s6 ))CDCI00000 <<>>r)Nc|tj}nt|}|j}|jrP|jd||j||jd||j |dS| D]\}}|||||j D]\}}||||dS)Nrrd) r)IsPythonDefaultSerializationDeterministicr5rr-rarerrrdr@rK)r write_bytes deterministicrrrr|rs r(InternalSerializez=_AddSerializePartialToStringMethod..InternalSerialize2s&  F H Hm=))mJ( !&// tx000(11 tz=22222,0??+<+<KK ' K!!+{MJJJJ$($8!! )[ I K    !!r)rU)rr)rSr!rrs r("_AddSerializePartialToStringMethodr)s?":#!!!!(-#r)czd}||_tjtj|jfd}||_dS)r:cBt|}t|} ||d||krtjdnO#t t f$rtjdtj$r}tj|d}~wwxYw|S)NrzUnexpected end-group tag.zTruncated message.) memoryviewr_InternalParserm DecodeError IndexErrorrstructerror)r serializedlengthrs r(r0z2_AddMergeFromStringMethod..MergeFromStringKsJ''J __F '  ZF 3 3v = =%&ABBB >  ":::  #$8 9 99 <'''  #A & &&' Ms/A3BBBc:t|tsJ||j}|j}||krY||\}}|d\}} ||jsg|_|tj|_|j}tj |d\} } tj | \} } | dkrtjd|}tj||| \}}|dkr|S|| | |||||}|dkr|S|j||||f|}n&||||||}| r|| ||kY|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. )NNNrzField number 0 is illegal.r^)rrrrJrLr rKrUnknownFieldSetr _DecodeVarintr UnpackTagrmr_DecodeUnknownField_addappendtobytesr")rbufferposend field_dictunknown_field_setr|new_posr field_desctag_r wire_typeold_posdatadecoders_by_tag local_ReadTaglocal_SkipFields r( InternalParsez0_AddMergeFromStringMethod..InternalParse_s fj ) ))) )NNJ/ ***]6377y'"1"5"5i"N"NmZ  # $!#$   $$.$>$@$@$ !"5 (A66a"-"7"<"< i 1  '(DEE E!5 GY((w b==*|Y===!/&'3 BB b==* ## ww/7799 : < < <mFGS$ CC  -   , , ,E **F Jr)N)r0rReadTag SkipFieldr+r)rSr!r0rrrrs @@@r(_AddMergeFromStringMethodrIsi   (#/-%/(/6666666n%#r)c\d|jDdfd }||_fd}||_dS)z[Adds the IsInitialized and FindInitializationError methods to the protocol message class.c<g|]}|jtjk|SrD)r[rYLABEL_REQUIRED)rr<s r(rz+_AddIsInitializedMethod..s5NNNu#k-=-LLLLLLr)NcD]^}||jvs'|jtjkr>|j|js,|'||dS_t|jD]\}}|jtjkr|j tj krr|j j r|j jrZ|D]C}|s-|'||dSD|jr@|s,|'||dSdS)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. NFT)rJrfrYrgrMrrrprr[rr`r,r-rar)rerrorsr<rdelementrequired_fieldss r(rz._AddIsInitializedMethod..IsInitializeds! t| # # >-= = =|E"8 >   --5577 8 8 8uuT\//1122 u +; ; ; ;*9 9 9 ,  ++--7    g((** # d;;==>>>UUU    ( 1D1D1F1F    MM$7799 : : : 4r)c g} D]6}||js||j7|D]"\}}|jt jkr|jr d|jz}n|j}t|rKt|r;|D]7}||}|d|d | }| fd|Dz }8|j t j krTtt|D]6}||}d||fz | }| fd|Dz }7|dz | }| fd|Dz }$|S) 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].cg|]}|zSrDrDrrprefixs r(rzM_AddIsInitializedMethod..FindInitializationErrors..s@@@E%@@@r)z%s[%d].cg|]}|zSrDrDrs r(rzM_AddIsInitializedMethod..FindInitializationErrors..s>>>%v~>>>r)rcg|]}|zSrDrDrs r(rzM_AddIsInitializedMethod..FindInitializationErrors..s<<<Ve^<<.FindInitializationErrorssF "" ]]5: & &" ej!!!))== u +; ; ;   %/)$$$ u   =  & &  A Ac g$(DD###.f";;==j@@@@Z@@@@ff  A  [,; ; ;U$$ ? ?aAhG$*F 99;;J >>>>:>>> >FF  ? #:&5577* <<<<<<< <& Mr)rU)r1rr)rSr!rrrs @r(_AddIsInitializedMethodrs|NN(:(ANNN/%%%%%%N$#*****X":#r)cX|j}t|d|j}|dvr|S|dz|zS)Nr?)Nbuiltins __builtin__r)r>rr=)klassmoduler"s r(_FullyQualifiedClassNamers=  &  7 7$ 000 K # r)cXtjtjfd}|_dS)Nct|s5tdtdt|jd||usJ||j}|jD]\}}|jkrG||}|| |}|||<| |W|j krN|j rF||}|| |}|||<| |||j|<|j r|||jrm|jsg|_|j|j|jt%j|_|j|jdSdS)NzBParameter to MergeFrom() must be instance of same class: expected z got r)rrrr'rrJrr[r rwrrfrMrrr"rKrrLrr_extend) rrfr1r<rdrrgrr!s r(rz&_AddMergeFromMethod..MergeFroms c3  M I#;C#@#@#@#@#;CM#J#J#J#J L M MM d????NN \F ))++(( u  & &jj''  22488+%&-e$$$$ >_ , ,  & ' 5))+  44T::K'F5M    & & &# U  ! (   ' ' ' >  !"! !!#"5666 (","<">"> %%c&<=====>>r))rYrrgr)r!rrgrs` @@r(_AddMergeFromMethodrsF#2.$4/(>(>(>(>(>(>(>T#---r)c fd}||_dS)Nc j|}n #t$rtd|zwxYw|j|d}|!||jr|jSdS)zDReturns the name of the currently set field inside a oneof, or None.z)Protocol message has no oneof "%s" field.N)rNrrrQr rFr")r oneof_namer< nested_fieldrSs r( WhichOneofz(_AddWhichOneofMethod..WhichOneof2sD / ;ee DDD  5 B D DDD<##E400LDMM,2C$D$D   Ts .)r)rSr!rs` r(_AddWhichOneofMethodr1s)     #...r)ci|_d|_|j |jd|_i|_|dS)NrD)rJrKrL_clearrQrrs r(_ClearrCsT$,$ (""$$$"D$,..r)cN|jtj|_|jSrU)rLrrrs r(_UnknownFieldsrPs% $(8::D  r)cg|_d|_|D]\}}|jtjkrt |r/t|r|D]}||X|j tj kr|D]}||dSrU) rKrLr@rfrYrgrbriDiscardUnknownFieldsr[r)rr<rdr sub_messages r(_DiscardUnknownFieldsrWs$ $oo'' % %leU ~)999 U  % e $ $ . . .c #J + + - - - - ;*9 9 9  - -K  * * , , , , - ""$$$ % %r)cL|tj|_dS||_dSrU)rrrN)rlisteners r(rrgs' )=??DNNNDNNNr)cnt||t||t|||jrt |t |t ||t||t||t||t||t||t||t||t||t|t!||t"|_t&|_t*|_t.|_dS)z3Adds implementations of all Message methods to cls.N)rArJrQrrVrZrwr~rrrrrrrrrrClearr UnknownFieldsrrr)rSr!s r(r8r8ns9)3///'---)3///% S!!!3%s+++"C(((#S)))&,,,'---0#666$%7===.444,c222c)3///#)$#2#!#r)c<d}d}||_||_||_dS)z5Adds implementation of private helper methods to cls.c~|js5d|_d|j_d|_|jdSdS)zwSets the _cached_byte_size_dirty bit to true, and propagates this to our listener iff this was a state change. TN)rIrOrrMrNModifiedrs r(rz*_AddPrivateHelperMethods..ModifiedsN  ' %)d"*.d!'#'d  n   r)c|j|j|}||ur|j|=||j|j<dSdS)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)rQr rrrJ)rr< other_fields r(r"z3_AddPrivateHelperMethods.._UpdateOneofStatesP ,))%*@%HHK% ,{ #-2dl5)*** r)N)r SetInParentr")rSr!rr"s r(r9r9s>     3 3 3#-#/+#r)ceZdZdZdZdZdS)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||_ntj||_d|_dS)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(r:z_Listener.__init__sD.'"344C%3d""%,]>%B%Bd" DJJJr)cn|jrdS |jdS#t$rYdSwxYwrU)rr rReferenceErrorrs r(rz_Listener.ModifiedsU z  f  ",,.....     dd  s & 44N)r=r>r?r@r:rrDr)r(rrs<  &      r)rc,eZdZdZfdZfdZxZS)rzCSpecial listener implementation for setting composite oneof fields.cftt||||_dS)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)rrr:_field)rrr<r's r(r:z_OneofListener.__init__s.  .$((888DKKKr)c |j|jtt|dS#t $rYdSwxYw)zEAlso updates the state of the containing oneof in the parent message.N)r r"rrrrr)rr's r(rz_OneofListener.Modifiedse  "44T[AAA ND!!**,,,,,     dd sAA AA)r=r>r?r@r:rrArBs@r(rrsWKK         r)r)Rr@ __author__iorrrr google.protobuf.internalrrrrrr r rr r r r_rrDrrmrFieldDescriptorrYrorrXrrFrr^rbrir2rr3rtrrr4rr5rrrrrrr6r7r8rArJrQrVrZrjrwr~rrrrrrrrrrrrrrrr8r9objectrrrDr)r(rsH  3  877777//////,,,,,,,,,,,,666666333333MMMMMM222222555555000000888888222222''''''!1(.@1@1@1@1@14@1@1@1V:((((:::555 AAA @<@<@