Duac@s!dZdZddlmZddlZddlZddlZddlZddlm Z ddlm Z ddlm Z ddlm Z dd lm Z dd lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZejZdZdefdYZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)d Z*d!Z+d"Z,d#Z-d$Z.d%Z/d&Z0d'Z1d(Z2d)Z3d*Z4d+Z5d,Z6d-Z7d.Z8d/Z9d0Z:d1Z;d2Z<d3Z=d4Z>d5Z?d6Z@d7ZAd8ZBd9ZCd:ZDd;ZEd<ZFd=ZGd>ZHd?ZId@ZJdAZKdBZLdCZMdDeNfdEYZOdFeOfdGYZPdHeNfdIYZQdS(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&eZdZdZdZdZRS(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|jjrPtj|df|jtj tjjj|}tjjj|}|_|_t_fd}|tjjtrtjjr|tjtndS(Ntproto2tpackedcstjj|}j}|tjkrHtjrHtj}nd}j dk rf}nrt }t j t|}n%tj|j|j}||fj|j}|jjdk 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.pytMakeSubMessageDefaults   csjS(N(t default_value(R (R.(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pytMakeScalarDefaults( RMR]RHR5Rkthas_default_valueRRRPRQRKRR(R.RRRR((R.RKRsK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRxs&    cCstjd}t|jdkrYt|tkrYtdt|||f}ntjt||tjddS(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_ReraiseTypeErrorWithFieldNames'"cs:dfd}d|_d|_||_dS(sAdds an __init__ method to cls.cSsXt|tjrTy|j|jSWqTtk rPtd|j|fqTXn|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"(R4Rt string_typestvalues_by_nameRWR6RR(RRN((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_GetIntegerEnumValues c sd|_t|dk|_i|_i|_d|_t|_tj |_ t ||_ xs|j D]e\}}t|}|dkrtdj|fn|dkrqmn|jtjkr|j|}|jtjkrt|rFt|r6x3|D]}||j||qWq|j|qx|D]8}t|trr|j|qM|jj|qMWnG|jtjkrg|D]}|j |^q}n|j!|||j|RmR?tmessage_listener_modtNullMessageListenerR@t _ListenerRARt_GetFieldByNameR!RRRHR5RkR_RPRQRMRSt MergeFromtupdateR4tdicttaddt CPPTYPE_ENUMRtextendRKR%RR( tselftkwargsRt field_valueR.tcopyRtvaltnew_val(RRE(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pytinits`           %   N(R!R0R1R-(RERR((RREsK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR's  =  cCs@y|j|SWn*tk r;td|j|fnXdS(sReturns 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(ROR6RR(RER((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRs  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 cCstjdkst|jjd}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_CPPTYPERRtupperRRWRHRkt_AddPropertiesForRepeatedFieldRPRQt*_AddPropertiesForNonRepeatedCompositeFieldt'_AddPropertiesForNonRepeatedScalarField(R.Rt constant_name((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR2s csvjt}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}|dkrEj|}|jj|}n|S(N(R=tgetR!R_t setdefault(RR(R.(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pytgetter\s  sGetter for %s.cstddS(NsIAssignment not allowed to repeated field "%s" in protocol message object.(tAttributeError(Rt 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!R0R1RR(R.Rt property_nameRRR((R.R2sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRKs     c sj}t|}tjjt}jjdk}fd}d |_ d||_ |o}j fdj rfd}n}d |_ d||_ d|}t ||t ||d|d S( sAdds 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|jjS(N(R=R(R(RR.(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRssGetter for %s.csYj|}r2| r2|jjdn ||j<|jsU|jndS(N(t CheckValueR=tpopR!R<t _Modified(RR(tclear_when_set_to_defaultR.R(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt field_setters    cs|||jdS(N(t_UpdateOneofState(RR(R.R(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRs sSetter for %s.s/Magic attribute generated for "%s" proto field.RN(RR3RRRtsetR8RnR!R0R1R[RR( R.RR2Rt valid_valuest is_proto3RRR((RRR.RRsK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRws$          csvjt}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}|dkrEj|}|jj|}n|S(N(R=RR!R_R(RR(R.(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRs  sGetter for %s.cstddS(NsJAssignment not allowed to composite field "%s" in protocol message object.(R(RR(R2(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRss/Magic attribute generated for "%s" proto field.RN(RR3R!R0R1RR(R.RRRRR((R.R2sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRs     cCs|j}x=|jD]/\}}|jd}t|||jqW|jdk r|jj}|j||_|j ||_ ndS(s=Adds properties for all fields in this protocol message type.RN( RRRRRWtfileR!tpoolt_extensions_by_numbert_extensions_by_name(R RRRRRR((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR)s  cs@fd}t|_fd}t|_dS(Ncs3j|_jjjj|t|dS(N(RR8RRtAddExtensionDescriptorR$(R9(R(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pytRegisterExtensions cs}|j||S(N(tMergeFromString(tsR (R(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt FromStrings  (t staticmethodRR(RRR((RsK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR*scCsM|djtjkr$t|dS|djtjkrE|djStSdS(sGiven 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 _IsPresents  cCsd}||_dS(s Helper for _AddMessageMethods().cSsEg|jjD]}t|r|^q}|jdd|S(NRcSs |djS(Ni(RW(R((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR R(R=RRtsort(RRt 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}|rtntix^|jD]S}|jtjkrOq1n|rw|jtjkrw|j rwq1n||j R(Rtothertany_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_AddEqualsMethods 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 _AddStrMethods 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_AddReprMethods cCsd}||_dS(s Helper for _AddMessageMethods().cSstj|dtjdS(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_AddUnicodeMethods 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_BytesForNonRepeatedElements   cCsd}||_dS(s Helper for _AddMessageMethods().cSs|js|jSd}|j}|jjrg|jdj|j}||jdj|j7}ndx-|j D]\}}||j|7}qtWx1|j D]&\}}|t |t |7}qW||_t |_t |j _|S(NiRRN(R<R;RRRLRORwRRNRR>RRmRAtdirty(RtsizeR RgRRbt value_bytes((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pytByteSizes      N(R1(RERR1((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_AddByteSizeMethods cCsd}||_dS(s Helper for _AddMessageMethods().c[sPg}|jsCtjd|jjdj|jfn|j|S(Ns)Message %s is missing required fields: %st,(t IsInitializedRR)RRtjointFindInitializationErrorstSerializePartialToString(RRterrors((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||jS(N(Rt_InternalSerializetwritetgetvalue(RRtout((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR7s cSs|dkrtj}n t|}|j}|jjr||jdj||j ||jdj||j |n^x-|j D]\}}|j|||qWx+|j D] \}}||||qWdS(NRRN( R!Rt)IsPythonDefaultSerializationDeterministicRRRRLRORvRRNRR>(Rt write_bytest deterministicR RgRRbR0((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}||_tjtj|j|jdkfd}||_dS(s Helper for _AddMessageMethods().cSst|}y1|j|d||kr<tjdnWnJttfk retjdn%tjk r}tj|nX|S(NisUnexpected end-group tag.sTruncated message.(Rt_InternalParseRt DecodeErrort IndexErrorRtstructterror(Rt serializedtlengthte((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR8s Rc s|j|j}|j}x||kr||\}}j|d\}} |dkr|} ||||}|dkr|S stjr|sg}|_n|j||| |!fn|}q||||||}| r|j| qqW|S(Ni(NN( RR=R>RR!Rt&GetPythonProto3PreserveUnknownsDefaulttappendR( Rtbuffertpostendt field_dicttunknown_field_listRbtnew_posRft field_desctvalue_start_pos(tdecoders_by_tagRt local_ReadTagtlocal_SkipField(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt InternalParseLs,       N(RRtReadTagt SkipFieldRRnRD(RERRRY((RVRRWRXsK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_AddMergeFromStringMethod6s    cseg|jD]}|jtjkr |^q dfd}||_fd}||_dS(s[Adds the IsInitialized and FindInitializationError methods to the protocol message class.cs`xfD]^}||jks?|jtjkr|j|j r|dk ra|j|jntSqWxt |jj D]\}}|jtjkr|j tj kr|j jr|j jjrqnx|D]8}|js|dk r|j|jntSqWqX|jrX|j rX|dk rQ|j|jntSqqWtS(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!RR6RmRRRHRkRKRRRLR4R{(RR8R.RNtelement(trequired_fields(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR4ns.  "       c sg}x3D]+}|j|js |j|jq q Wxw|jD]i\}}|jtjkrI|jrd|j}n |j}t |rt |rxX|D]M}||}d||f}|j }|g|D]} || ^q7}qWqq|j tj krxxtt|D]M} || }d|| f}|j }|g|D]} || ^qZ7}q$Wq|d}|j }|g|D]} || ^q7}qIqIW|S(sFinds 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.(RoRRMRRPR5RQR7RRMRSR6RHRktrangeR( RR8R.RNRRR]tprefixt sub_errorsRHti(R^(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR6s6        (  (  (N(R#RHR5tLABEL_REQUIREDR!R4R6(RERR.R4R6((R^sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_AddIsInitializedMethodgs ' ,cs4tjtjfd}|_dS(Ncst|s1tdj|jjfn||k sCt|j|j}x|jjD]\}}|jkr|j |}|dkr|j |}|||R(RRR#R.RNR(RQRkR(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRs8            (R5RkRQR(RR((RQRkRsK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_AddMergeFromMethods  %csfd}||_dS(Ncswyj|}Wn!tk r4td|nX|jj|d}|dk ro|j|jro|jSdSdS(sDReturns the name of the currently set field inside a oneof, or None.s)Protocol message has no oneof "%s" field.N(RR6RRCRR!RoR(Rt oneof_nameR.t nested_field(RE(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt WhichOneofs (Rj(RERRj((REsK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_AddWhichOneofMethodscCsd}||_dS(NcSst|d|jfS(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|_|jdS(N((R=R>RCR(R((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_Clear s   cCsyg|_xi|jD][\}}|jtjkr|jtjkrdx%|D]}|jqMWqq|jqqWdS(N(R>RRPR5RQRHRktDiscardUnknownFields(RR.RNt sub_message((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_DiscardUnknownFieldss  cCs+|dkrtj|_n ||_dS(N(R!RRR@(Rtlistener((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRs cCst||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(RRRRRRRR 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|_|jjndS(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    RcBs eZdZdZdZRS(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|tjr||_ntj||_t|_dS(sArgs: parent_message: The message whose _Modified() method we should call when we receive Modified() messages. N(R4tweakreft ProxyTypet_parent_message_weakreftproxyRmR.(Rtparent_message((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR-ns  cCs6|jr dSy|jjWntk r1nXdS(N(R.RzRtReferenceError(R((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRus   (R/R0R1R-Ru(((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR`s  RcBs eZdZdZdZRS(sCSpecial listener implementation for setting composite oneof fields.cCs#tt|j|||_dS(sArgs: 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-t_field(RR|R.((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR-scCsBy*|jj|jtt|jWntk r=nXdS(sEAlso updates the state of the containing oneof in the parent message.N(RzRR~RRRuR}(R((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRus  (R/R0R1R-Ru(((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRs RcBsVeZdZdZdZdZdZdZdZdZ dZ RS( sDict-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(Rtextended_message((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR-scCst|j||jjj|}|dk r5|S|jtjkr\|j|j}nV|j tj kr|j j }y|j |jjWqtk rqXn|jS|jjj||}|S(s8Returns the current value of the given extension handle.N(R:RR=RR!RHR5RkR_RPRQRKR%RRAR}RR(RR9R((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt __getitem__s     cCst||jstS|jj}|jj}g|D]}|jr;|^q;}g|D]}|jr]|^q]}||kS(N(R4RfRmRRR7(RRt my_fieldst other_fieldsR.((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRs""cCs ||k S(N((RR((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt__ne__scCstddS(Nsunhashable object(R(R((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt__hash__scCst|j||jtjks4|jtjkrJtd|jnt 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:RRHR5RkRPRQRRRRRR=R(RR9RNR((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt __setitem__scCs|jjj|dS(sTries to find a known extension with the specified name. Args: name: Extension full name. Returns: Extension field descriptor. N(RRRR!(RR((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_FindExtensionByNames cCs|jjj|dS(sTries to find a known extension with the field number. Args: number: Extension field number. Returns: Extension field descriptor. N(RRRR!(RRW((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_FindExtensionByNumbers ( R/R0R1R-RRRRRRR(((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRs  !    (RR1t __author__tioRRGRRxRtgoogle.protobuf.internalRRRRRRRRRR RR RR RR tFieldDescriptorR5RRFR R3R:RRJRMRSR$RR&R]RxRR'RR(RRRRR)R*RRRRRRRRRRR R"R'R-R2R:RCR\ReRgRkRnRoRrRR+R,tobjectRRR(((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt1s     k       C    7 T   , 8 ,    * &  (        1 _ ,      ".