ó SÉLjc@s!dZdZddlmZddlZddlZddlZddlZddlm Z ddlm Z ddlm Z ddlm Z dd lm Z dd lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZejZdZdefd„ƒYZd„Zd„Zd„Z d„Z!d„Z"d„Z#d„Z$d„Z%d„Z&d„Z'd„Z(d„Z)d „Z*d!„Z+d"„Z,d#„Z-d$„Z.d%„Z/d&„Z0d'„Z1d(„Z2d)„Z3d*„Z4d+Z5d,Z6d-„Z7d.„Z8d/„Z9d0„Z:d1„Z;d2„Z<d3„Z=d4„Z>d5„Z?d6„Z@d7„ZAd8„ZBd9„ZCd:„ZDd;„ZEd<„ZFd=„ZGd>„ZHd?„ZId@„ZJdA„ZKdB„ZLdC„ZMdDeNfdE„ƒYZOdFeOfdG„ƒYZPdHeNfdI„ƒYZQdS(Js 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*. s#robinson@google.com (Will Robinson)iÿÿÿÿ(tBytesION(tapi_implementation(t containers(tdecoder(tencoder(tenum_type_wrapper(tmessage_listener(t type_checkers(twell_known_types(t wire_format(t descriptor(tmessage(t text_formatsgoogle.protobuf.AnytGeneratedProtocolMessageTypecBs&eZdZdZd„Zd„ZRS(sQMetaclass 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 ... t DESCRIPTORcCs~|tj}|jtjkr9|tj|jf7}nt||ƒt||ƒtt|ƒ}|j||||ƒ}|S(sCustom 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. ( R t_DESCRIPTOR_KEYt full_nameRtWKTBASESt&_AddClassAttributesForNestedExtensionst _AddSlotstsupert__new__(tclstnametbasest dictionaryR t superclasst new_class((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRis   cCsø|tj}i|_|jrP|jƒjrPtj|ƒdf|jtj tjˆjˆjˆ|ƒ}tjˆjˆjˆ|ƒ}|ˆ_|ˆ_tˆƒˆ_‡‡‡‡fd†}|tjˆjtƒˆrÈtjˆjƒrÈ|tjtƒndS(Ntproto2tpackedcsÒtjˆj|ƒ}ˆj}|tjkrHtjˆƒrHtj}nd}ˆj dk rfˆ}nˆr–t ˆƒ}t j ˆtˆƒ|ƒ}n%tj|ˆjˆ|ˆˆjƒ}||fˆj|ˆjƒ}|jˆjdk r0t|ˆƒn|jƒ|S(N(R%t _SetListenerR[R!t_OneofListenerRA(R tresult(R.RK(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pytMakeSubMessageDefault¨s   csˆjS(N(t default_value(R (R.(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pytMakeScalarDefault±s( RMR]RHR5Rkthas_default_valueRŸR”RPRQRKRR•(R.R—RšRžR ((R.RKR™sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRx�s&    cCs€tjƒd}t|jƒdkrYt|ƒtkrYtdt|ƒ||fƒ}ntjt|ƒ|tjƒdƒdS(sCRe-raise the currently-handled TypeError with the field name added.is%s for field %s.%siN( tsystexc_infotlentargsRFt TypeErrortstrtsixtreraise(t message_namet field_nametexc((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_ReraiseTypeErrorWithFieldName¸s'"cs:d„‰‡‡fd†}d|_d|_||_dS(sAdds an __init__ method to cls.cSsXt|tjƒrTy|j|jSWqTtk rPtd|j|fƒ‚qTXn|S(sConvert 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.) s Enum type %s: unknown label "%s"(R4R¨t string_typestvalues_by_nameRWR6R”R(RŠRN((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_GetIntegerEnumValueÆs c sÚd|_t|ƒdk|_i|_i|_d|_t|_tj ƒ|_ t |ƒ|_ xs|j ƒD]e\}}tˆ|ƒ}|dkr°tdˆj|fƒ‚n|dkrÂqmn|jtjkrã|j|ƒ}|jtjkrŒt|ƒrFt|ƒr6x3|D]}||j||ƒqWq‰|j|ƒqÓxŠ|D]8}t|tƒrr|j|�qM|jƒj|ƒqMWnG|jtjkrÆg|D]}ˆ|j |ƒ^q¥}n|j!|ƒ||j|RmR?tmessage_listener_modtNullMessageListenerR@t _ListenerRAR�t_GetFieldByNameR!R¦RRHR5RkR_RPRQRMRSt MergeFromtupdateR4tdicttaddt CPPTYPE_ENUMRŠtextendRKR%R­R‡( tselftkwargsR«t field_valueR.tcopyRŒtvaltnew_val(R°RE(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pytinitÕs`           %   N(R!R0R1R-(RERRÁ((R°REsK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR'Ãs  =  cCs@y|j|SWn*tk r;td|j|fƒ‚nXdS(sóReturns 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. s&Protocol message %s has no "%s" field.N(ROR6R”R(RER«((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR´s  cCsCx|jD]}t||ƒq W|jr?td„ƒ|_ndS(s=Adds properties for all fields in this protocol message type.cSs t|ƒS(N(t_ExtensionDict(R»((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt/tN(R#t_AddPropertiesForFieldt is_extendabletpropertyt Extensions(R RR.((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR('s cCs�tjdkst‚|jjƒd}t|||jƒ|jtjkr]t ||ƒn/|j tj krt ||ƒn t ||ƒdS(s#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. i t _FIELD_NUMBERN(R5t MAX_CPPTYPER‚RtupperR‡RWRHRkt_AddPropertiesForRepeatedFieldRPRQt*_AddPropertiesForNonRepeatedCompositeFieldt'_AddPropertiesForNonRepeatedScalarField(R.Rt constant_name((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRÅ2s csvˆj‰tˆƒ}‡fd†}d|_dˆ|_‡fd†}dˆ}t||t||d|ƒƒdS(sAdds 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. csI|jjˆƒ}|dkrEˆj|ƒ}|jjˆ|ƒ}n|S(N(R=tgetR!R_t setdefault(R»R½(R.(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pytgetter\s  sGetter for %s.cstdˆƒ‚dS(NsIAssignment not allowed to repeated field "%s" in protocol message object.(tAttributeError(R»t new_value(R2(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pytsetteross/Magic attribute generated for "%s" proto field.tdocN(RR3R!R0R1R‡RÇ(R.Rt property_nameRÒRÕRÖ((R.R2sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRÌKs     c süˆj}t|ƒ}tjˆƒ‰ˆj‰tƒ}ˆjjdk}‡‡fd†}d |_ d||_ |o}ˆj ‰‡‡‡fd†‰ˆj r³‡‡fd†}nˆ}d |_ d||_ d|}t ||t ||d|ƒƒd S( s Adds a public property for a nonrepeated, scalar protocol message field. Clients can use this property to get and directly set the value of the field. Note that when the client sets the value of a field by using this property, all necessary "has" bits are set as a side-effect, and we also perform type-checking. Args: field: A FieldDescriptor for this field. cls: The class we're constructing. tproto3cs|jjˆˆƒS(N(R=RÐ(R»(RŸR.(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRÒ‰ssGetter for %s.csYˆj|ƒ}ˆr2| r2|jjˆdƒn ||jˆ<|jsU|jƒndS(N(t CheckValueR=tpopR!R<t _Modified(R»RÔ(tclear_when_set_to_defaultR.R™(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt field_setter’s    csˆ||ƒ|jˆƒdS(N(t_UpdateOneofState(R»RÔ(R.RÝ(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRÕ¡s sSetter for %s.s/Magic attribute generated for "%s" proto field.RÖN(RR3RR•RŸtsetR8RnR!R0R1R[R‡RÇ( R.RR2R×t valid_valuest is_proto3RÒRÕRÖ((RÜRŸR.RÝR™sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRÎws$          csvˆj‰tˆƒ}‡fd†}d|_dˆ|_‡fd†}dˆ}t||t||d|ƒƒdS(sNAdds a public property for a nonrepeated, composite protocol message field. A composite field is a "group" or "message" field. Clients can use this property to get the value of the field, but cannot assign to the property directly. Args: field: A FieldDescriptor for this field. cls: The class we're constructing. csI|jjˆƒ}|dkrEˆj|ƒ}|jjˆ|ƒ}n|S(N(R=RÐR!R_RÑ(R»R½(R.(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRÒ¿s  sGetter for %s.cstdˆƒ‚dS(NsJAssignment not allowed to composite field "%s" in protocol message object.(RÓ(R»RÔ(R2(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRÕÒss/Magic attribute generated for "%s" proto field.RÖN(RR3R!R0R1R‡RÇ(R.RR×RÒRÕRÖ((R.R2sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRͯs     cCs‹|j}x=|jƒD]/\}}|jƒd}t|||jƒqW|jdk r‡|jj}|j||_|j ||_ ndS(s=Adds properties for all fields in this protocol message type.RÉN( R€R�RËR‡RWtfileR!tpoolt_extensions_by_numbert_extensions_by_name(R RRƒR„R…RÏRã((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR)Ûs  cs@‡fd†}t|ƒˆ_‡fd†}t|ƒˆ_dS(Ncs3ˆj|_ˆjjjj|ƒtˆ|ƒdS(N(RR8RâRãtAddExtensionDescriptorR$(R9(R(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pytRegisterExtensionìs csˆƒ}|j|ƒ|S(N(tMergeFromString(tsR (R(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt FromStringós  (t staticmethodRçRê(RRçRê((RsK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR*êscCsM|djtjkr$t|dƒS|djtjkrE|djStSdS(sˆGiven a (FieldDescriptor, value) tuple from _fields, return true if the value should be included in the list returned by ListFields().iiN(RHR5RktboolRPRQR?R{(titem((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt _IsPresentús  cCsd„}||_dS(s Helper for _AddMessageMethods().cSsEg|jjƒD]}t|ƒr|^q}|jdd„ƒ|S(NRŒcSs |djS(Ni(RW(Rí((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRà RÄ(R=R�Rîtsort(R»Rít all_fields((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt ListFields s.N(Rñ(RERRñ((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_AddListFieldsMethods s:Protocol message has no non-repeated submessage field "%s"s/Protocol message has no non-repeated field "%s"csÔ|jdk}|rtnt‰i‰x^|jD]S}|jtjkrOq1n|rw|jtjkrw|j rwq1n|ˆ|j Rï(R»tothertany_atany_btunknown_fieldstother_unknown_fields((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt__eq__§s"       N(R(RERR((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_AddEqualsMethod¥s cCsd„}||_dS(s Helper for _AddMessageMethods().cSs tj|ƒS(N(R tMessageToString(R»((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt__str__ÅsN(R(RERR((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt _AddStrMethodÃs cCsd„}||_dS(s Helper for _AddMessageMethods().cSs tj|ƒS(N(R R(R»((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt__repr__ÌsN(R!(RERR!((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_AddReprMethodÊs cCsd„}||_dS(s Helper for _AddMessageMethods().cSstj|dtƒjdƒS(Ntas_utf8sutf-8(R RR{tdecode(R»((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt __unicode__ÔsN(R%(tunused_message_descriptorRR%((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_AddUnicodeMethodÑs cCsIytj|}|||ƒSWn$tk rDtjd|ƒ‚nXdS(s 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. sUnrecognized field type: %dN(RtTYPE_TO_BYTE_SIZE_FNR6Rt EncodeError(RNt field_numbert field_typetfn((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_BytesForNonRepeatedElementÙs   cCsd„}||_dS(s Helper for _AddMessageMethods().cSsí|js|jSd}|j}|jƒjrg|jdj|jƒ}||jdj|jƒ7}ndx-|j ƒD]\}}||j|ƒ7}qtWx1|j D]&\}}|t |ƒt |ƒ7}q¡W||_t |_t |j _|S(NiRŒRN(R<R;RRRLRORwRŒRNRñR>R¤RmRAtdirty(R»tsizeR RgR½Rbt value_bytes((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pytByteSizeðs      N(R1(RERR1((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_AddByteSizeMethodís cCsd„}||_dS(s Helper for _AddMessageMethods().c[sPg}|jƒsCtjd|jjdj|jƒƒfƒ‚n|j|�S(Ns)Message %s is missing required fields: %st,(t IsInitializedRR)RRtjointFindInitializationErrorstSerializePartialToString(R»R¼terrors((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pytSerializeToString s  (N(R9(RERR9((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_AddSerializeToStringMethods cCs+d„}||_dd„}||_dS(s Helper for _AddMessageMethods().c[s&tƒ}|j|j|�|jƒS(N(Rt_InternalSerializetwritetgetvalue(R»R¼tout((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR7s cSsÞ|dkrtjƒ}n t|ƒ}|j}|jƒjr||jdj||j |ƒ|jdj||j |ƒn^x-|j ƒD]\}}|j|||ƒq‰Wx+|j D] \}}||ƒ||ƒq¶WdS(NRŒRN( R!Rt)IsPythonDefaultSerializationDeterministicRìRRRLRORvRŒRNRñR>(R»t write_bytest deterministicR RgR½RbR0((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pytInternalSerializes      N(R7R!R;(RERR7RB((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt"_AddSerializePartialToStringMethods   csad„}||_tj‰tj‰|j‰|jdk‰‡‡‡‡fd†}||_dS(s Helper for _AddMessageMethods().cSsŽt|ƒ}y1|j|d|ƒ|kr<tjdƒ‚nWnJttfk retjdƒ‚n%tjk r‰}tj|ƒ‚nX|S(NisUnexpected end-group tag.sTruncated message.(R¤t_InternalParseRt DecodeErrort IndexErrorR¦tstructterror(R»t serializedtlengthte((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRè8s RØc s|jƒ|j}|j}xñ||krˆ||ƒ\}}ˆj|dƒ\}} |dkrÞ|} ˆ||||ƒ}|dkr�|Sˆ s¢tjƒrÕ|s¸g}|_n|j||| |!fƒn|}q||||||ƒ}| r|j| ƒqqW|S(Niÿÿÿÿ(NN( RÛR=R>RÐR!Rt&GetPythonProto3PreserveUnknownsDefaulttappendRÞ( R»tbuffertpostendt field_dicttunknown_field_listRbtnew_posRft field_desctvalue_start_pos(tdecoders_by_tagRát local_ReadTagtlocal_SkipField(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt InternalParseLs,       N(RèRtReadTagt SkipFieldRRnRD(RERRèRY((RVRáRWRXsK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_AddMergeFromStringMethod6s    cseg|jD]}|jtjkr |^q ‰d‡fd†}||_‡fd†}||_dS(s[Adds the IsInitialized and FindInitializationError methods to the protocol message class.cs`xfˆD]^}||jks?|jtjkr|j|j r|dk ra|j|jƒƒntSqWxðt |jj ƒƒD]Ù\}}|jtjkr|j tj kr|j jrÓ|j jƒjrÓqnx|D]8}|jƒsÚ|dk r|j|jƒƒntSqÚWqX|jrX|jƒ rX|dk rQ|j|jƒƒntSqqWtS(sChecks 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. N(R=RPR5RQR?R!RºR6RmRR�RHRkRKRRRLR4R{(R»R8R.RNtelement(trequired_fields(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR4ns.  "       c sºg}x3ˆD]+}|j|jƒs |j|jƒq q Wxw|jƒD]i\}}|jtjkrI|jr€d|j}n |j}t |ƒrÿt |ƒr¯xX|D]M}||}d||f}|j ƒ}|g|D]} || ^qÞ7}q¨Wq¯q²|j tj krxx›tt|ƒƒD]M} || }d|| f}|j ƒ}|g|D]} || ^qZ7}q$Wq²|d}|j ƒ}|g|D]} || ^q˜7}qIqIW|S(sÆFinds 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". s(%s)s%s[%s].s%s[%d].t.(RoRRMRñRPR5RQR7RRMRSR6RHRktrangeR¤( R»R8R.RNRRŒR]tprefixt sub_errorsRHti(R^(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR6—s6        (  (  (N(R#RHR5tLABEL_REQUIREDR!R4R6(RERR.R4R6((R^sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_AddIsInitializedMethodgs ' ,cs4tj‰tj‰‡‡‡fd†}|ˆ_dS(NcsŒt|ˆƒs1tdˆj|jjfƒ‚n||k sCt‚|jƒ|j}xû|jjƒD]ê\}}|jˆkrÈ|j |ƒ}|dkr¸|j |ƒ}|||Rº(R»RR#R.RNR½(RQRkR(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRµÊs8            (R5RkRQRµ(RRµ((RQRkRsK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_AddMergeFromMethodÆs  %cs‡fd†}||_dS(Ncswyˆj|}Wn!tk r4td|ƒ‚nX|jj|dƒ}|dk ro|j|jƒro|jSdSdS(sDReturns the name of the currently set field inside a oneof, or None.s)Protocol message has no oneof "%s" field.N(RýR6R”RCRÐR!RoR(R»t oneof_nameR.t nested_field(RE(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt WhichOneofós (Rj(RERRj((REsK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_AddWhichOneofMethodòscCsd„}||_dS(NcSst|ƒd|jƒfS(N((RFt __getstate__(R»((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt __reduce__s(Rm(RRm((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_AddReduceMethods cCs)i|_d|_i|_|jƒdS(N((R=R>RCRÛ(R»((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_Clear s   cCsyg|_xi|jƒD][\}}|jtjkr|jtjkrdx%|D]}|jƒqMWqq|jƒqqWdS(N(R>RñRPR5RQRHRktDiscardUnknownFields(R»R.RNt sub_message((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_DiscardUnknownFieldss  cCs+|dkrtjƒ|_n ||_dS(N(R!R±R²R@(R»tlistener((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR›s cCsüt||ƒt||ƒt||ƒ|jrGt|ƒt|ƒnt||ƒt||ƒt||ƒt ||ƒt ||ƒt ||ƒt ||ƒt ||ƒt||ƒt|ƒt||ƒt|ƒt|_t|_t|_dS(s3Adds implementations of all Message methods to cls.N(RòRûRRÆRRRR R"R'R2R:RCR\ReRgRkRnRotClearRrRpR›(RER((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR+$s*                    cCs1d„}d„}||_||_||_dS(s5Adds implementation of private helper methods to cls.cSs;|js7t|_t|j_t|_|jjƒndS(swSets the _cached_byte_size_dirty bit to true, and propagates this to our listener iff this was a state change. N(R<R{RAR.R?R@tModified(R»((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRuAs    cSsE|jj|j|ƒ}||k rA|j|=||j|js    R³cBs eZdZd„Zd„ZRS(s0MessageListener implementation that a parent message registers with its child message. In order to support semantics like: foo.bar.baz.qux = 23 assert foo.HasField('bar') ...child objects must have back references to their parents. This helper class is at the heart of this support. cCs=t|tjƒr||_ntj|ƒ|_t|_dS(s�Args: parent_message: The message whose _Modified() method we should call when we receive Modified() messages. N(R4tweakreft ProxyTypet_parent_message_weakreftproxyRmR.(R»tparent_message((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR-ns  cCs6|jr dSy|jjƒWntk r1nXdS(N(R.RzRÛtReferenceError(R»((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRu�s   (R/R0R1R-Ru(((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR³`s  RœcBs eZdZd„Zd„ZRS(sCSpecial listener implementation for setting composite oneof fields.cCs#tt|ƒj|ƒ||_dS(sËArgs: 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(RRœR-t_field(R»R|R.((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR-‘scCsBy*|jj|jƒtt|ƒjƒWntk r=nXdS(sEAlso updates the state of the containing oneof in the parent message.N(RzRÞR~RRœRuR}(R»((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRušs  (R/R0R1R-Ru(((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRœŽs RÂcBsVeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z RS( s«Dict-like container for supporting an indexable "Extensions" field on proto instances. Note that in all cases we expect extension handles to be FieldDescriptors. cCs ||_dS(sMextended_message: Message instance for which we are the Extensions dict. N(t_extended_message(R»textended_message((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR-°scCsÎt|j|ƒ|jjj|ƒ}|dk r5|S|jtjkr\|j|jƒ}nV|j tj kr«|j j ƒ}y|j |jjƒWq²tk r§q²Xn|jS|jjj||ƒ}|S(s8Returns the current value of the given extension handle.N(R:RR=RÐR!RHR5RkR_RPRQRKR%R›RAR}RŸRÑ(R»R9R�((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt __getitem__¶s     cCs‚t||jƒstS|jjƒ}|jjƒ}g|D]}|jr;|^q;}g|D]}|jr]|^q]}||kS(N(R4RfRmRRñR7(R»Rt my_fieldst other_fieldsR.((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR×s""cCs ||k S(N((R»R((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt__ne__äscCstdƒ‚dS(Nsunhashable object(R¦(R»((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt__hash__çscCsƒt|j|ƒ|jtjks4|jtjkrJtd|jƒ‚nt j |ƒ}|j |ƒ|jj |<|jj ƒdS(slIf extension_handle specifies a non-repeated, scalar extension field, sets the value of that field. sKCannot assign to extension "%s" because it is a repeated or composite type.N(R:RRHR5RkRPRQR¦RRR•RÙR=RÛ(R»R9RNR™((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt __setitem__îscCs|jjj|dƒS(s™Tries to find a known extension with the specified name. Args: name: Extension full name. Returns: Extension field descriptor. N(RRåRÐR!(R»R((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_FindExtensionByNames cCs|jjj|dƒS(sœTries to find a known extension with the field number. Args: number: Extension field number. Returns: Extension field descriptor. N(RRäRÐR!(R»RW((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_FindExtensionByNumbers ( R/R0R1R-R�RR„R…R†R‡Rˆ(((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR§s  !    (RR1t __author__tioRRGR¢RxR¨tgoogle.protobuf.internalRRRRRRR±RRR RR RóR RR tFieldDescriptorR5RRFR R3R:RRJRMRSR$RR&R]RxR­R'R´R(RÅRÌRÎRÍR)R*RîRòR÷RøRûRRRRRR R"R'R-R2R:RCR\ReRgRkRnRoRrR›R+R,tobjectR³RœRÂ(((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt1s�     k       C    7 T   , 8 ,    * &  (        1 _ ,      ".