AlkantarClanX12

Your IP : 3.144.17.181


Current Path : /lib/python2.7/site-packages/google/protobuf/internal/
Upload File :
Current File : //lib/python2.7/site-packages/google/protobuf/internal/python_message.pyo

�
Du�ac@s!dZdZddlmZddlZddlZddlZddlZddlm	Z	ddlm
Z
ddlmZddlmZdd	lm
Z
dd
lmZddlmZdd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(twire_format(t
descriptor(tmessage(ttext_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	<nx|j
D]}t||�qZW||_t
||�t||�t||�t||�t|�t||�t||�tt|�}|j|||�dS(s�Here 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.
    N(R
Rt_decoders_by_tagthas_optionst
GetOptionstmessage_set_wire_formatRtMessageSetItemDecodertNonetMESSAGE_SET_ITEM_TAGtfieldst_AttachFieldHelperst_concrete_classt_AddEnumValuest_AddInitMethodt_AddPropertiesForFieldst_AddPropertiesForExtensionst_AddStaticMethodst_AddMessageMethodst_AddPrivateHelperMethodsRt__init__(RRRRR
tfieldR((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR-�s"
		"	






(t__name__t
__module__t__doc__RRR-(((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR
Ns	cCs|S(sReturns 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.
  ((tproto_field_name((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt
_PropertyName�scCs�t|t�s"td|��n|jsAtd|j��n|js`td|j��n|j|jk	r�td|j|jj|jjf��ndS(s0Verify that the given extension handle is valid.s3HasExtension() expects an extension handle, got: %ss"%s" is not an extension.s""%s" is missing a containing_type.sKExtension "%s" extends message type "%s", but this message is of type "%s".N(t
isinstancet_FieldDescriptortKeyErrortis_extensionRtcontaining_typeR(Rtextension_handle((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_VerifyExtensionHandle�s
			c	Cs)ddddddddd	g	|d
<dS(s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.
  t_cached_byte_sizet_cached_byte_size_dirtyt_fieldst_unknown_fieldst_is_present_in_parentt	_listenert_listener_for_childrent__weakref__t_oneofst	__slots__N((tmessage_descriptorR((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR�scCsI|joH|jjoH|jj�joH|jtjkoH|jtj	kS(N(
R7R8RRRttypeR5tTYPE_MESSAGEtlabeltLABEL_OPTIONAL(R.((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_IsMessageSetExtension�s
	cCs.|jtjko-|jjo-|jj�jS(N(RFR5RGtmessage_typeRRt	map_entry(R.((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_IsMapFieldscCs |jjd}|jtjkS(Ntvalue(RKtfields_by_nametcpp_typeR5tCPPTYPE_MESSAGE(R.t
value_type((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_IsMessageMapField
scs��jtjk��o'tj�j�}|s9t}ng�jjdkrf�j	o`�j
�j}n:�j	o��j
�jd�o��j
�jtk}|}t
����r�tj��}tj�t���}nqt��rtj�j�}tj�j�}n>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|<dS(N(RtTagBytestnumberRFR5t	TYPE_ENUMRtSupportsOpenEnumst
TYPE_INT32R!tcontaining_oneofRSRt
MapDecodert_GetInitializeDefaultForMaptTYPE_TO_DECODERt_default_constructorR(twiretypet	is_packedt	tag_bytestdecode_typetoneof_descriptortis_message_mapt
field_decoder(Rtfield_descriptortis_map_entrytis_repeated(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt
AddDecoder4s"		
( RHR5tLABEL_REPEATEDR	tIsTypePackableRFtFalseR8tsyntaxRRRUtHasFieldRMRt
MapEncodertMapSizerRSRJtMessageSetItemEncoderRWtMessageSetItemSizerRtTYPE_TO_ENCODERt
TYPE_TO_SIZERt_encodert_sizert _DefaultValueConstructorForFieldR_tFIELD_TYPE_TO_WIRE_TYPEtWIRETYPE_LENGTH_DELIMITEDtTrue(RRgtis_packableRathas_packed_falset
field_encodertsizerRj((RRgRhRisK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR$sB				

		cCs4|j}x$|j�D]\}}|||<qWdS(N(textensions_by_nametitems(R
Rtextension_dicttextension_nametextension_field((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRUs	cCs^xW|jD]L}t||jtj|��x'|jD]}t||j|j�q6Wq
WdS(sSets 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(t
enum_typestsetattrRRtEnumTypeWrappertvaluesRW(R
Rt	enum_typet
enum_value((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR&\s	cs��jtjkr(td�j��n�jj}tj|d��|d�t	��rv���fd�}|Stj������fd�}|SdS(Ns&map_entry set on non-repeated field %stkeyRNcstj|j�j��j�S(N(Rt
MessageMapRARK(R(R.tkey_checkertvalue_field(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pytMakeMessageMapDefaulttscstj|j���j�S(N(Rt	ScalarMapRARK(R(R.R�t
value_checker(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pytMakePrimitiveMapDefault{s(
RHR5Rkt
ValueErrorRRKRORtGetTypeCheckerRS(R.ROR�R�((R.R�R�R�sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR]ks
cs�t��rt��S�jtjkr��jrV�jgkrVtd�j��n�jtj	kr��j
��fd�}|Stj����fd�}|Sn�jtj	kr��j
���fd�}|S�fd�}|S(s�Returns 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.
  s/Repeated field default value not empty list: %scstj|j�j�S(N(RtRepeatedCompositeFieldContainerRARK(R(R.(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pytMakeRepeatedMessageDefault�scstj|j��S(N(RtRepeatedScalarFieldContainerRA(R(ttype_checker(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pytMakeRepeatedScalarDefault�scs>�j�}|j�jdk	r0t|��n|j�|S(N(R%t_SetListenerR[R!t_OneofListenerRA(Rtresult(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|<qm|jtjkrs|j|�}|}t|t�r.|j"j#|�}ny|j|�Wn!tk
rbt$�j|�nX||j|<qm|jtjkr��|j |�}nyt%|||�Wqmtk
r�t$�j|�qmXqmWdS(Nis,%s() got an unexpected keyword argument '%s'((&R;R�R<R=RCR>RmR?tmessage_listener_modtNullMessageListenerR@t	_ListenerRAR�t_GetFieldByNameR!R�RRHR5RkR_RPRQRMRSt	MergeFromtupdateR4tdicttaddtCPPTYPE_ENUMR�textendRKR%R�R�(	tselftkwargsR�tfield_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<lambda>/tN(R#t_AddPropertiesForFieldt
is_extendabletpropertyt
Extensions(R
RR.((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR('s	cCs{|jj�d}t|||j�|jtjkrHt||�n/|jtj	krjt
||�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.
  t
_FIELD_NUMBERN(RtupperR�RWRHR5Rkt_AddPropertiesForRepeatedFieldRPRQt*_AddPropertiesForNonRepeatedCompositeFieldt'_AddPropertiesForNonRepeatedScalarField(R.Rt
constant_name((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR�2scsv�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���jr���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
<q1W|s�x!|jD]}|�|j
<q�Wn���fd���|_dS(s Helper for _AddMessageMethods().R�cs�y�|}Wn!tk
r1t�|��nXt|tj�rwy�||j|j�SWq�tk
rstSXnD|jt	j
kr�|jj|�}|dk	o�|jS||jkSdS(N(R6R�R4tdescriptor_modtOneofDescriptorRCRRmRPR5RQR=R�R!R?(R�R�R.RN(Rot	error_msgthassable_fields(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRo(s

N(
Rnt_Proto3HasErrort_Proto2HasErrorR#RHR5RkRPRQR[RtoneofsRo(RERR�R.toneof((RoR�R�sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_AddHasFieldMethods
cs�fd�}||_dS(s Helper for _AddMessageMethods().csy�j|}Wnrtk
r�y4�j|}||jkrP|j|}ndSWq�tk
r�td�j|f��q�XnX||jkr�t|j|d�r�|j|j�n|j|=|jj	|j
d�|kr�|j|j
=q�n|j�dS(Ns(Protocol message %s() has no "%s" field.tInvalidateIterators(
ROR6toneofs_by_nameRCR�RR=thasattrR�R�R[R!R�(R�R�R.(RE(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt
ClearField?s$



N(R�(RERR�((REsK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_AddClearFieldMethod=s!cCsd�}||_dS(s Helper for _AddMessageMethods().cSs7t||�||jkr)|j|=n|j�dS(N(R:R=R�(R�R9((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pytClearExtensiones

N(R�(RR�((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_AddClearExtensionMethodcs	cCsd�}||_dS(s Helper for _AddMessageMethods().cSs}t||�|jtjkr5td|j��n|jtjkrl|jj	|�}|dk	ok|jS||jkSdS(Ns"%s" is repeated.(R:RHR5RkR6RRPRQR=R�R!R?(R�R9RN((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pytHasExtensionqs
N(R(RR((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_AddHasExtensionMethodos	
cCs�ddlm}|j�}|j}|s/dS|jd�d}|jj|�}|dkrddS|j|�}|�}|j	|j
�|S(stUnpacks 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.
  i����(tsymbol_databaset/N(tgoogle.protobufRtDefaultttype_urlR!tsplitR�tFindMessageTypeByNametGetPrototypetParseFromStringRN(tmsgRtfactoryRt	type_nameR
t
message_classR((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_InternalUnpackAny}s		cCsd�}||_dS(s Helper for _AddMessageMethods().cSs�t|tj�s%|j|jkr)tS||kr9tS|jjtkr|t|�}t|�}|r||r|||kSn|j	�|j	�ks�tSt
|j�}|j�t
|j�}|j�||kS(N(
R4tmessage_modtMessageRRmR{Rt_AnyFullTypeNameRR�tlistR>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_FNR6RtEncodeError(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�Rbtvalue_bytes((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pytByteSize�s		 		N(R/(RERR/((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.pytSerializeToStrings(N(R7(RERR7((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.pyR5s	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�twrite_bytest
deterministicR
RgR�RbR.((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pytInternalSerializes	


N(R5R!R9(RERR5R@((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_InternalParseRtDecodeErrort
IndexErrorR�tstructterror(R�t
serializedtlengthte((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR�8sR�cs|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	SkipFieldRRnRB(RERR�RW((RTR�RURVsK/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|jtj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�R4RmRR�RHRkRKRRRLR2R{(R�R6R.RNtelement(trequired_fields(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR2ns.

"
cs�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.(RoRRKR�RPR5RQR7RRMRSR4RHRktrangeR�(R�R6R.RNRR�R[tprefixt
sub_errorsRFti(R\(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR4�s6
		

(
(
(N(R#RHR5tLABEL_REQUIREDR!R2R4(RERR.R2R4((R\sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_AddIsInitializedMethodgs'	,cs4tj�tj����fd�}|�_dS(Ncszt|��s1td�j|jjf��n|j�|j}x�|jj�D]�\}}|j�kr�|j|�}|dkr�|j
|�}|||<n|j|�qT|j�kr|j
r>|j|�}|dkr|j
|�}|||<n|j|�q>qT||j|<|jrT|j|�qTqTW|jrv|js`g|_n|jj|j�ndS(NsLParameter to MergeFrom() must be instance of same class: expected %s got %s.(R4R�R/t	__class__R�R=R�RHR�R!R_R�RPR?R[R�R>R�(R�RR#R.RNR�(RQRkR(sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR��s6
	
	

			(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
(Rh(RERRh((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(Rk(RRk((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.RNtsub_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�R�R�RRRRR R%R0R8RARZRcReRiRlRmtClearRpRnR�(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.pyRsAs
				cSsE|jj|j|�}||k	rA|j|=||j|j<ndS(s�Sets 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(RCR�R[R=(R�R.tother_field((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR�Ps
N(R�tSetInParentR�(RERRsR�((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR,>s
				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,RxR�tReferenceError(R�((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRs�s	
(R/R0R1R-Rs(((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�RzR.((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(RxR�R|RR�RsR{(R�((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyRs�s

(R/R0R1R-Rs(((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�|jj�}y|j
|jj�Wq�tk
r�q�Xn|jS|jjj||�}|S(s8Returns the current value of the given extension handle.N(R:R}R=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(R4RdRmR}R�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:R}RHR5RkRPRQR�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(R}R�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(R}R�R�R!(R�RW((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt_FindExtensionByNumbers	(R/R0R1R-RRR�R�R�R�R�(((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyR��s		!	
				(RR1t
__author__tioRRER�RvR�tgoogle.protobuf.internalRRRRRRR�RRR	RR
R�RRRtFieldDescriptorR5RRFR
R3R:RRJRMRSR$RR&R]RxR�R'R�R(R�R�R�R�R)R*R�R�R�R�R�R�RRRRRR R%R+R0R8RARZRcReRiRlRmRpR�R+R,tobjectR�R�R�(((sK/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.pyt<module>1s�	k							C				7		T				,	8	,				
	*	&			(								 	1	_	,							".