Q,Qc@sqdZdZddlmZejdkrfejdkrSddlmZqfddlmZnde fd YZ d e fd YZ d e fd YZ de fdYZdefdYZde fdYZdefdYZde fdYZdefdYZde fdYZde fdYZdZdd Zd!S("sDescriptors essentially contain exactly the information found in a .proto file, in types that make this information accessible in Python. s#robinson@google.com (Will Robinson)i(tapi_implementationtcppi(t_message(t cpp_messagetErrorcBseZdZRS(sBase error for this module.(t__name__t __module__t__doc__(((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyR0stTypeTransformationErrorcBseZdZRS(sHError transforming between python proto type and corresponding C++ type.(RRR(((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyR4stDescriptorBasecBs)eZdZdZdZdZRS(sDescriptors base class. This class is the base of all descriptor classes. It provides common options related functionaility. Attributes: has_options: True if the descriptor has non-default options. Usually it is not necessary to read this -- just call GetOptions() which will happily return the default instance. However, it's sometimes useful for efficiency, and also useful inside the protobuf implementation to avoid some bootstrapping issues. cCs%||_||_|dk |_dS(sInitialize the descriptor given its options message and the name of the class of the options message. The name of the class is required in case the options message is None and has to be created. N(t_optionst_options_class_nametNonet has_options(tselftoptionstoptions_class_name((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyt__init__Gs  cCs%||_||_|dk |_dS(sSets the descriptor's options This function is used in generated proto2 files to update descriptor options. It must not be used outside proto2. N(R R R R (RRR((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyt _SetOptionsRs  cCsp|jr|jSddlm}yt||j}Wn$tk r\td|jnX||_|jS(sRetrieves descriptor options. This method returns the options set or creates the default options for the descriptor. i(tdescriptor_pb2sUnknown options class name %s!(R tgoogle.protobufRtgetattrR tAttributeErrort RuntimeError(RRt options_class((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyt GetOptions^s   (RRRRRR(((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyR 8s  t_NestedDescriptorBasecBs/eZdZdddZdZdZRS(s0Common class for descriptors that can be nested.c CsStt|j||||_||_||_||_||_||_dS(sCConstructor. Args: options: Protocol message options or None to use default message options. options_class_name: (str) The class name of the above options. name: (str) Name of this protocol message type. full_name: (str) Fully-qualified name of this protocol message type, which will include protocol "package" name and the name of any enclosing types. file: (FileDescriptor) Reference to file info. containing_type: if provided, this is a nested descriptor, with this descriptor as parent, otherwise None. serialized_start: The start index (inclusive) in block in the file.serialized_pb that describes this descriptor. serialized_end: The end index (exclusive) in block in the file.serialized_pb that describes this descriptor. N( tsuperRRtnamet full_nametfiletcontaining_typet_serialized_startt_serialized_end( RRRRRRRtserialized_starttserialized_end((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyRss      cCs)|}x|jdk r$|j}q W|S(sEReturns the root if this is a nested type, or itself if its the root.N(RR (Rtdesc((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pytGetTopLevelContainingTypes cCs`|jdk rP|jdk rP|jdk rP|j|jj|j|j!n tddS(sCopies this to the matching proto in descriptor_pb2. Args: proto: An empty proto instance from descriptor_pb2. Raises: Error: If self couldnt be serialized, due to to few constructor arguments. s*Descriptor does not contain serialization.N(RR R R!tParseFromStringt serialized_pbR(Rtproto((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyt CopyToProtos N(RRRR RR%R)(((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyRps  ! t DescriptorcBs;eZdZdedddddZdZdZRS(sIDescriptor for a protocol message type. A Descriptor instance has the following attributes: name: (str) Name of this protocol message type. full_name: (str) Fully-qualified name of this protocol message type, which will include protocol "package" name and the name of any enclosing types. containing_type: (Descriptor) Reference to the descriptor of the type containing us, or None if this is top-level. fields: (list of FieldDescriptors) Field descriptors for all fields in this type. fields_by_number: (dict int -> FieldDescriptor) Same FieldDescriptor objects as in |fields|, but indexed by "number" attribute in each FieldDescriptor. fields_by_name: (dict str -> FieldDescriptor) Same FieldDescriptor objects as in |fields|, but indexed by "name" attribute in each FieldDescriptor. nested_types: (list of Descriptors) Descriptor references for all protocol message types nested within this one. nested_types_by_name: (dict str -> Descriptor) Same Descriptor objects as in |nested_types|, but indexed by "name" attribute in each Descriptor. enum_types: (list of EnumDescriptors) EnumDescriptor references for all enums contained within this type. enum_types_by_name: (dict str ->EnumDescriptor) Same EnumDescriptor objects as in |enum_types|, but indexed by "name" attribute in each EnumDescriptor. enum_values_by_name: (dict str -> EnumValueDescriptor) Dict mapping from enum value name to EnumValueDescriptor for that value. extensions: (list of FieldDescriptor) All extensions defined directly within this message type (NOT within a nested type). extensions_by_name: (dict, string -> FieldDescriptor) Same FieldDescriptor objects as |extensions|, but indexed by "name" attribute of each FieldDescriptor. is_extendable: Does this type define any extension ranges? options: (descriptor_pb2.MessageOptions) Protocol message options or None to use default message options. file: (FileDescriptor) Reference to file descriptor. c Csjtt|j| d||| |d| d| ||_x|jD]}||_qDWtd|D|_td|D|_||_td|D|_ ||_ x|j D]}||_qWtd|D|_ td|D|_ ||_ x|j D]}||_qWtd |D|_| |_| |_| |_||_d S( sArguments to __init__() are as described in the description of Descriptor fields above. Note that filename is an obsolete argument, that is not used anymore. Please use file.name to access this as an attribute. tMessageOptionsR"R#css|]}|j|fVqdS(N(tnumber(t.0tf((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pys scss|]}|j|fVqdS(N(R(R-R.((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pys scss|]}|j|fVqdS(N(R(R-tt((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pys scss|]}|j|fVqdS(N(R(R-R/((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pys scss.|]$}|jD]}|j|fVqqdS(N(tvaluesR(R-R/tv((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pys scss|]}|j|fVqdS(N(R(R-R.((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pys sN(RR*RtfieldsRtdicttfields_by_numbertfields_by_namet nested_typestnested_types_by_namet enum_typestenum_types_by_nametenum_values_by_namet extensionstextension_scopetextensions_by_namet is_extendabletextension_rangesR R!(RRRtfilenameRR2R6R8R;RR>R?RR"R#tfieldt enum_typet extension((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyRs2            cCs|j|j|jS(ssReturns the string name of an enum value. This is just a small helper method to simplify a common operation. Args: enum: string name of the Enum. value: int, value of the enum. Returns: string name of the enum value. Raises: KeyError if either the Enum doesn't exist or the value is not a valid value for the enum. (R9tvalues_by_numberR(Rtenumtvalue((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyt EnumValueNamescCstt|j|dS(svCopies this to a descriptor_pb2.DescriptorProto. Args: proto: An empty descriptor_pb2.DescriptorProto. N(RR*R)(RR(((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyR)"sN(RRRR tTrueRRGR)(((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyR*s 1 + tFieldDescriptorcBs|eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZd Zd Zd Z iee6ee6ee6ee6ee6ee6ee6ee6ee6ee6ee6ee6ee 6ee6ee 6ee 6ee 6ee 6Z!dZ"dZ#dZ$dZ%de'dZ(e)dZ*RS(sDescriptor for a single field in a .proto file. A FieldDescriptor instance has the following attributes: name: (str) Name of this field, exactly as it appears in .proto. full_name: (str) Name of this field, including containing scope. This is particularly relevant for extensions. index: (int) Dense, 0-indexed index giving the order that this field textually appears within its message in the .proto file. number: (int) Tag number declared for this field in the .proto file. type: (One of the TYPE_* constants below) Declared type. cpp_type: (One of the CPPTYPE_* constants below) C++ type used to represent this field. label: (One of the LABEL_* constants below) Tells whether this field is optional, required, or repeated. has_default_value: (bool) True if this field has a default value defined, otherwise false. default_value: (Varies) Default value of this field. Only meaningful for non-repeated scalar fields. Repeated fields should always set this to [], and non-repeated composite fields should always set this to None. containing_type: (Descriptor) Descriptor of the protocol message type that contains this field. Set by the Descriptor constructor if we're passed into one. Somewhat confusingly, for extension fields, this is the descriptor of the EXTENDED message, not the descriptor of the message containing this field. (See is_extension and extension_scope below). message_type: (Descriptor) If a composite field, a descriptor of the message type contained in this field. Otherwise, this is None. enum_type: (EnumDescriptor) If this field contains an enum, a descriptor of that enum. Otherwise, this is None. is_extension: True iff this describes an extension field. extension_scope: (Descriptor) Only meaningful if is_extension is True. Gives the message that immediately contains this extension field. Will be None iff we're a top-level (file-level) extension field. options: (descriptor_pb2.FieldOptions) Protocol message field options or None to use default field options. iiiiiiiii i i i i iiiiicCs4tt|j|d||_||_||_||_||_||_||_ ||_ ||_ | |_ | |_ | |_| |_| |_tjdkr'| rtjdkrtj||_q$tj||_q0tjdkrtj||_q0tj||_n d|_dS(sThe arguments are as described in the description of FieldDescriptor attributes above. Note that containing_type may be None, and may be set later if necessary (to deal with circular references between message types, for example). Likewise for extension_scope. t FieldOptionsRiN(RRIRRRtindexR,ttypetcpp_typetlabelthas_default_valuet default_valueRt message_typeRBt is_extensionR<RtTypetVersionRtGetExtensionDescriptort _cdescriptorRtGetFieldDescriptorR (RRRRKR,RLRMRNRPRQRBRRRR<RRO((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyRs0               cCs7ytj|SWn!tk r2td|nXdS(sConverts from a Python proto type to a C++ Proto Type. The Python ProtocolBuffer classes specify both the 'Python' datatype and the 'C++' datatype - and they're not the same. This helper method should translate from one to another. Args: proto_type: the Python proto type (descriptor.FieldDescriptor.TYPE_*) Returns: descriptor.FieldDescriptor.CPPTYPE_*, the C++ type. Raises: TypeTransformationError: when the Python proto type isn't known. sUnknown proto_type: %sN(RIt_PYTHON_TO_CPP_PROTO_TYPE_MAPtKeyErrorR(t proto_type((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pytProtoTypeToCppProtoTypes N(+RRRt TYPE_DOUBLEt TYPE_FLOATt TYPE_INT64t TYPE_UINT64t TYPE_INT32t TYPE_FIXED64t TYPE_FIXED32t TYPE_BOOLt TYPE_STRINGt TYPE_GROUPt TYPE_MESSAGEt TYPE_BYTESt TYPE_UINT32t TYPE_ENUMt TYPE_SFIXED32t TYPE_SFIXED64t TYPE_SINT32t TYPE_SINT64tMAX_TYPEt CPPTYPE_INT32t CPPTYPE_INT64tCPPTYPE_UINT32tCPPTYPE_UINT64tCPPTYPE_DOUBLEt CPPTYPE_FLOATt CPPTYPE_BOOLt CPPTYPE_ENUMtCPPTYPE_STRINGtCPPTYPE_MESSAGEt MAX_CPPTYPERXtLABEL_OPTIONALtLABEL_REQUIREDtLABEL_REPEATEDt MAX_LABELR RHRt staticmethodR[(((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyRI7sr-  %tEnumDescriptorcBs/eZdZddddddZdZRS(sDescriptor for an enum defined in a .proto file. An EnumDescriptor instance has the following attributes: name: (str) Name of the enum type. full_name: (str) Full name of the type, including package name and any enclosing type(s). values: (list of EnumValueDescriptors) List of the values in this enum. values_by_name: (dict str -> EnumValueDescriptor) Same as |values|, but indexed by the "name" field of each EnumValueDescriptor. values_by_number: (dict int -> EnumValueDescriptor) Same as |values|, but indexed by the "number" field of each EnumValueDescriptor. containing_type: (Descriptor) Descriptor of the immediate containing type of this enum, or None if this is an enum defined at the top level in a .proto file. Set by Descriptor's constructor if we're passed into one. file: (FileDescriptor) Reference to file descriptor. options: (descriptor_pb2.EnumOptions) Enum options message or None to use default enum options. c Cstt|j|d||||d|d|||_x|jD]} || _qDWtd|D|_td|D|_||_| |_ dS(sArguments are as described in the attribute description above. Note that filename is an obsolete argument, that is not used anymore. Please use file.name to access this as an attribute. t EnumOptionsR"R#css|]}|j|fVqdS(N(R(R-R1((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pys scss|]}|j|fVqdS(N(R,(R-R1((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pys sN( RRRR0RLR3tvalues_by_nameRDR R!( RRRR@R0RRRR"R#RF((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyRs    cCstt|j|dS(s~Copies this to a descriptor_pb2.EnumDescriptorProto. Args: proto: An empty descriptor_pb2.EnumDescriptorProto. N(RRR)(RR(((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyR)sN(RRRR RR)(((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyRs tEnumValueDescriptorcBseZdZdddZRS(s,Descriptor for a single value within an enum. name: (str) Name of this value. index: (int) Dense, 0-indexed index giving the order that this value appears textually within its enum in the .proto file. number: (int) Actual number assigned to this enum value. type: (EnumDescriptor) EnumDescriptor to which this value belongs. Set by EnumDescriptor's constructor if we're passed into one. options: (descriptor_pb2.EnumValueOptions) Enum value options message or None to use default enum value options options. cCsAtt|j|d||_||_||_||_dS(s>Arguments are as described in the attribute description above.tEnumValueOptionsN(RRRRRKR,RL(RRRKR,RLR((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyR1s    N(RRRR R(((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyR"s tServiceDescriptorcBs5eZdZdddddZdZdZRS(sDescriptor for a service. name: (str) Name of the service. full_name: (str) Full name of the service, including package name. index: (int) 0-indexed index giving the order that this services definition appears withing the .proto file. methods: (list of MethodDescriptor) List of methods provided by this service. options: (descriptor_pb2.ServiceOptions) Service options message or None to use default service options. file: (FileDescriptor) Reference to file info. c Csdtt|j|d|||dd|d|||_||_x|jD]} || _qMWdS(NtServiceOptionsR"R#(RRRR RKtmethodstcontaining_service( RRRRKRRRR"R#tmethod((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyRIs   cCs+x$|jD]}||jkr |Sq WdS(s>Searches for the specified method, and returns its descriptor.N(RRR (RRR((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pytFindMethodByNameUscCstt|j|dS(sCopies this to a descriptor_pb2.ServiceDescriptorProto. Args: proto: An empty descriptor_pb2.ServiceDescriptorProto. N(RRR)(RR(((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyR)\sN(RRRR RRR)(((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyR:s   tMethodDescriptorcBseZdZddZRS(sDescriptor for a method in a service. name: (str) Name of the method within the service. full_name: (str) Full name of method. index: (int) 0-indexed index of the method inside the service. containing_service: (ServiceDescriptor) The service that contains this method. input_type: The descriptor of the message that this method accepts. output_type: The descriptor of the message that this method returns. options: (descriptor_pb2.MethodOptions) Method options message or None to use default method options. cCsStt|j|d||_||_||_||_||_||_dS(sThe arguments are as described in the description of MethodDescriptor attributes above. Note that containing_service may be None, and may be set later if necessary. t MethodOptionsN( RRRRRRKRt input_typet output_type(RRRRKRRRR((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyRus     N(RRRR R(((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyRfs tFileDescriptorcBs&eZdZdddZdZRS(sDescriptor for a file. Mimics the descriptor_pb2.FileDescriptorProto. name: name of file, relative to root of source tree. package: name of the package serialized_pb: (str) Byte string of serialized descriptor_pb2.FileDescriptorProto. cCstt|j|di|_||_||_||_tjdkr|jdk rtj dkrt j |jqt j |jndS(s Constructor.t FileOptionsRiN(RRRtmessage_types_by_nameRtpackageR'RRSR RTRt BuildFileR(RRRRR'((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyRs    cCs|j|jdS(s~Copies this to a descriptor_pb2.FileDescriptorProto. Args: proto: An empty descriptor_pb2.FileDescriptorProto. N(R&R'(RR(((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyR)sN(RRRR RR)(((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyRscCs|j||S(sParses serialized options. This helper function is used to parse serialized options in generated proto2 files. It must not be used outside proto2. (R&(tmessagetstring((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyt _ParseOptionss tcCs|jg}|r%|jd|ng}x|jD]}dj||jg}t|j||jd|j|jtj|j|jddddt ddt }|j |q5Wdj|}t |j|dd|gggS(s Make a protobuf Descriptor given a DescriptorProto protobuf. Args: desc_proto: The descriptor_pb2.DescriptorProto protobuf message. package: Optional package name for the new message Descriptor (string). Returns: A Descriptor for protobuf messages. it.iRON( RtinsertRAtjoinRIR,RLR[RNR tFalsetappendR*(t desc_protoRtfull_message_nameR2t field_protoRRAt desc_name((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pytMakeDescriptors   N(Rt __author__tgoogle.protobuf.internalRRSRTtgoogle.protobuf.internal.cppRRt ExceptionRRtobjectR RR*RIRRRRRRR(((s>/usr/lib/python2.7/site-packages/google/protobuf/descriptor.pyt!s&8?9,!