U Xzf_(@sdZdZddlZddlZddlZddlmZdZedkr\ddl Z ddl Z ddl m Z dZGd d d e ZGd d d eZerGd ddeZneZGdddeZeZddZde_eZGdddeeZGdddeZGdddeZGdddeZGdddeZGdddeZGd d!d!eZ Gd"d#d#eZ!Gd$d%d%eZ"Gd&d'd'eZ#d(d)Z$d*d+Z%d,d-Z&d.d/Z'd3d1d2Z(dS)4zDescriptors essentially contain exactly the information found in a .proto file, in types that make this information accessible in Python. z#robinson@google.com (Will Robinson)N)api_implementationFcpp)_messageTc@seZdZdZdS)ErrorzBase error for this module.N__name__ __module__ __qualname____doc__r r r/private/var/folders/n9/53xbvtmd7sjg1q1l55xmpg58n4mgng/T/pip-unpacked-wheel-3cr5c46n/google/protobuf/descriptor.pyr4src@seZdZdZdS)TypeTransformationErrorzHError transforming between python proto type and corresponding C++ type.Nrr r r r r 8sr cseZdZfddZZS)DescriptorMetaclasscs(tt||rdSt||jr$dSdS)NTF)superr__instancecheck__ isinstance_C_DESCRIPTOR_CLASS)clsobj __class__r r rBs  z%DescriptorMetaclass.__instancecheck__)rrr r __classcell__r r rr rAsrc@s(eZdZdZddZddZddZdS) _Lockz>Wrapper class of threading.Lock(), which is allowed by 'with'.cCst|}t|_|SN)object__new__ threadingLock_lock)rselfr r r rPs  z _Lock.__new__cCs|jdSr)racquirerr r r __enter__Usz_Lock.__enter__cCs|jdSr)rrelease)rexc_type exc_valueexc_tbr r r __exit__Xsz_Lock.__exit__N)rrr r rr"r'r r r r rMsrcCs0tjdkr,tjd8_tjd|tdddS)NrzCall to deprecated create function %s(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool.)category stacklevel) _DeprecatedcountwarningswarnDeprecationWarningnamer r r r,_s r,dc@s0eZdZdZerdZddZddZddZd S) DescriptorBaseaDescriptors base class. This class is the base of all descriptor classes. It provides common options related functionality. 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. r cCs(||_||_||_|dk p |dk |_dS)zInitialize 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)_options_options_class_name_serialized_options has_options)roptionsserialized_optionsoptions_class_namer r r __init__szDescriptorBase.__init__cCs||_||_|dk |_dS)zSets the descriptor's options This function is used in generated proto2 files to update descriptor options. It must not be used outside proto2. N)r5r6r8)rr9r;r r r _SetOptionsszDescriptorBase._SetOptionsc Cs|jr |jSddlm}zt||j}Wn"tk rJtd|jYnXt8|jdkrf||_nt ||j|_|jW5QRSQRXdS)zRetrieves descriptor options. This method returns the options set or creates the default options for the descriptor. rdescriptor_pb2zUnknown options class name %s!N) r5google.protobufr?getattrr6AttributeError RuntimeErrorrr7 _ParseOptions)rr?Z options_classr r r GetOptionss$    zDescriptorBase.GetOptionsN) rrr r _USE_C_DESCRIPTORSrr<r=rEr r r r r4rs    r4cs*eZdZdZdfdd ZddZZS)_NestedDescriptorBasez0Common class for descriptors that can be nested.Nc s<tt||| |||_||_||_||_||_||_dS)aConstructor. 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. serialized_options: Protocol message serialized options or None. N) rrGr<r2 full_namefilecontaining_type_serialized_start_serialized_end) rr9r;r2rHrIrJserialized_startserialized_endr:rr r r<s z_NestedDescriptorBase.__init__cCsF|jdk r:|jdk r:|jdk r:||jj|j|jntddS)zCopies 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. Nz*Descriptor does not contain serialization.)rIrKrLParseFromString serialized_pbrrprotor r r CopyToProtos   z!_NestedDescriptorBase.CopyToProto)NNN)rrr r r<rSrr r rr rGs #rGc sVeZdZdZer ejZdddZdfdd Z e dd Z d d Z fd d Z ZS) Descriptora= Descriptor for a protocol message type. 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[FieldDescriptor]): Field descriptors for all fields in this type. fields_by_number (dict(int, FieldDescriptor)): Same :class:`FieldDescriptor` objects as in :attr:`fields`, but indexed by "number" attribute in each FieldDescriptor. fields_by_name (dict(str, FieldDescriptor)): Same :class:`FieldDescriptor` objects as in :attr:`fields`, but indexed by "name" attribute in each :class:`FieldDescriptor`. nested_types (list[Descriptor]): Descriptor references for all protocol message types nested within this one. nested_types_by_name (dict(str, Descriptor)): Same Descriptor objects as in :attr:`nested_types`, but indexed by "name" attribute in each Descriptor. enum_types (list[EnumDescriptor]): :class:`EnumDescriptor` references for all enums contained within this type. enum_types_by_name (dict(str, EnumDescriptor)): Same :class:`EnumDescriptor` objects as in :attr:`enum_types`, but indexed by "name" attribute in each EnumDescriptor. enum_values_by_name (dict(str, EnumValueDescriptor)): Dict mapping from enum value name to :class:`EnumValueDescriptor` for that value. extensions (list[FieldDescriptor]): All extensions defined directly within this message type (NOT within a nested type). extensions_by_name (dict(str, FieldDescriptor)): Same FieldDescriptor objects as :attr:`extensions`, but indexed by "name" attribute of each FieldDescriptor. is_extendable (bool): Does this type define any extension ranges? oneofs (list[OneofDescriptor]): The list of descriptors for oneof fields in this message. oneofs_by_name (dict(str, OneofDescriptor)): Same objects as in :attr:`oneofs`, but indexed by "name" attribute. file (FileDescriptor): Reference to file descriptor. NTcCstjtj|Sr)rMessage_CheckCalledFromGeneratedFile default_poolZFindMessageTypeByName)rr2rHfilenamerJfields nested_types enum_types extensionsr9r: is_extendableextension_rangesoneofsrIrMrNsyntax create_keyr r r r!s zDescriptor.__new__c sh|tk rtdtt|j| d||||||| d ||_|jD] }||_q>tdd|D|_tdd|D|_ d|_ ||_ |D] }||_qtdd|D|_ ||_ |j D] }||_qtd d|D|_td d|D|_||_|jD] }||_qtd d|D|_| |_| |_| dk r(| ng|_td d|jD|_|jD] }||_qJ|p`d |_dS)zArguments 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. rTZMessageOptionsrMrNr:css|]}|j|fVqdSrnumber.0fr r r Isz&Descriptor.__init__..css|]}|j|fVqdSrr1rer r r rhJsNcss|]}|j|fVqdSrr1rftr r r rhPscss|]}|j|fVqdSrr1rir r r rhUscss$|]}|jD]}|j|fVq qdSr)valuesr2)rfrjvr r r rhVscss|]}|j|fVqdSrr1rer r r rh\scss|]}|j|fVqdSrr1)rfor r r rh`sproto2)_internal_create_keyr,rrTr<rYrJdictZfields_by_numberZfields_by_name_fields_by_camelcase_namerZZnested_types_by_namer[enum_types_by_nameZenum_values_by_namer\extension_scopeextensions_by_namer]r^r_Zoneofs_by_namer`)rr2rHrXrJrYrZr[r\r9r:r]r^r_rIrMrNr`rafield nested_type enum_type extensionZoneofrr r r<-sR         zDescriptor.__init__cCs&|jdkr tdd|jD|_|jS)zrSame FieldDescriptor objects as in :attr:`fields`, but indexed by :attr:`FieldDescriptor.camelcase_name`. Ncss|]}|j|fVqdSr)camelcase_namerer r r rhksz6Descriptor.fields_by_camelcase_name..)rqrprYr!r r r fields_by_camelcase_namees   z#Descriptor.fields_by_camelcase_namecCs|j|j|jS)asReturns 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. )rrvalues_by_numberr2)renumvaluer r r EnumValueNameoszDescriptor.EnumValueNamecstt||dS)zvCopies this to a descriptor_pb2.DescriptorProto. Args: proto: An empty descriptor_pb2.DescriptorProto. N)rrTrSrQrr r rSszDescriptor.CopyToProto) NNTNNNNNNN) NNTNNNNNNN)rrr r rFrrTrrr<propertyrzr~rSrr r rr rTs:+ 8 rTc$s0eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZd Zd Zd Z d Z!eeeeeeeeeeeeeee eeeeeeeeee eeee ee eee e e iZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)e*re+j,Z-d!ddZ.d"fdd Z/e0ddZ1e2dd Z3Z4S)#FieldDescriptora+ Descriptor for a single field in a .proto file. 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 (int): (One of the TYPE_* constants below) Declared type. cpp_type (int): (One of the CPPTYPE_* constants below) C++ type used to represent this field. label (int): (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. containing_oneof (OneofDescriptor): If the field is a member of a oneof union, contains its descriptor. Otherwise, None. file (FileDescriptor): Reference to file descriptor. r(r) ii8JiNNTcCs*tj| rtj|Stj|SdSr)rrUrVrWFindExtensionByNameFindFieldByName)rr2rHindexrdtypecpp_typelabel default_value message_typerwrJ is_extensionrsr9r:has_default_valuecontaining_oneof json_namerIrar r r rs  zFieldDescriptor.__new__cs|tk rtdtt|||d||_||_||_d|_|dkrPt ||_ n||_ ||_ ||_ ||_ ||_||_||_||_| |_| |_| |_| |_| |_||_tdkr| rtj||_qtj||_nd|_dS)aThe 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. rZ FieldOptionsNr)ror,rrr<r2rHrI_camelcase_name _ToJsonNamerrrdrrrrrrJrrwrrsrrTyperrWrZ _cdescriptorr)rr2rHrrdrrrrrrwrJrrsr9r:rrrrIrarr r r<$s@    zFieldDescriptor.__init__cCs|jdkrt|j|_|jS)zRCamelcase name of this field. Returns: str: the name in CamelCase. N)r _ToCamelCaser2r!r r r rySs  zFieldDescriptor.camelcase_namecCs2z tj|WStk r,td|YnXdS)aConverts 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: int: descriptor.FieldDescriptor.CPPTYPE_*, the C++ type. Raises: TypeTransformationError: when the Python proto type isn't known. zUnknown proto_type: %sN)r_PYTHON_TO_CPP_PROTO_TYPE_MAPKeyErrorr )Z proto_typer r r ProtoTypeToCppProtoType^s z'FieldDescriptor.ProtoTypeToCppProtoType)NNTNNNN)NNTNNNN)5rrr r Z TYPE_DOUBLEZ TYPE_FLOATZ TYPE_INT64Z TYPE_UINT64Z TYPE_INT32Z TYPE_FIXED64Z TYPE_FIXED32Z TYPE_BOOLZ TYPE_STRINGZ TYPE_GROUPZ TYPE_MESSAGEZ TYPE_BYTESZ TYPE_UINT32Z TYPE_ENUMZ TYPE_SFIXED32Z TYPE_SFIXED64Z TYPE_SINT32Z TYPE_SINT64ZMAX_TYPEZ CPPTYPE_INT32Z CPPTYPE_INT64ZCPPTYPE_UINT32ZCPPTYPE_UINT64ZCPPTYPE_DOUBLEZ CPPTYPE_FLOATZ CPPTYPE_BOOLZ CPPTYPE_ENUMZCPPTYPE_STRINGZCPPTYPE_MESSAGEZ MAX_CPPTYPErZLABEL_OPTIONALZLABEL_REQUIREDZLABEL_REPEATEDZ MAX_LABELZMAX_FIELD_NUMBERZFIRST_RESERVED_FIELD_NUMBERZLAST_RESERVED_FIELD_NUMBERrFrrrrr<rry staticmethodrrr r rr rs5 / rcsBeZdZdZer ejZd ddZd fdd Z fddZ Z S) EnumDescriptoraDescriptor for an enum defined in a .proto file. 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[EnumValueDescriptors]): List of the values in this enum. values_by_name (dict(str, EnumValueDescriptor)): Same as :attr:`values`, but indexed by the "name" field of each EnumValueDescriptor. values_by_number (dict(int, EnumValueDescriptor)): Same as :attr:`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. Nc Cstjtj|Sr)rrUrVrWZFindEnumTypeByName) rr2rHrXrkrJr9r:rIrMrNrar r r rs zEnumDescriptor.__new__c sz| tk rtdtt|j|d||||| | |d ||_|jD] } || _q>tdd|D|_tddt |D|_ dS)zArguments 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. rZ EnumOptionsrbcss|]}|j|fVqdSrr1rfrlr r r rhsz*EnumDescriptor.__init__..css|]}|j|fVqdSrrcrr r r rhsN) ror,rrr<rkrrpZvalues_by_namereversedr{) rr2rHrXrkrJr9r:rIrMrNrar}rr r r<s$   zEnumDescriptor.__init__cstt||dS)zCopies this to a descriptor_pb2.EnumDescriptorProto. Args: proto (descriptor_pb2.EnumDescriptorProto): An empty descriptor proto. N)rrrSrQrr r rSszEnumDescriptor.CopyToProto)NNNNNNN)NNNNNNN) rrr r rFrrrrr<rSrr r rr rss( rcs6eZdZdZer ejZdddZdfdd Z Z S) EnumValueDescriptoraLDescriptor for a single value within an enum. Attributes: 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): :class:`EnumDescriptor` to which this value belongs. Set by :class:`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. NcCstjdSr)rrUrV)rr2rrdrr9r:rar r r rs zEnumValueDescriptor.__new__cs@|tk rtdtt|||d||_||_||_||_dS)>Arguments are as described in the attribute description above.rZEnumValueOptionsN) ror,rrr<r2rrdr)rr2rrdrr9r:rarr r r<s zEnumValueDescriptor.__init__)NNNN)NNNN) rrr r rFrrrrr<rr r rr rs rcs6eZdZdZer ejZdddZdfdd Z Z S) OneofDescriptora'Descriptor for a oneof field. Attributes: name (str): Name of the oneof field. full_name (str): Full name of the oneof field, including package name. index (int): 0-based index giving the order of the oneof field inside its containing type. containing_type (Descriptor): :class:`Descriptor` of the protocol message type that contains this field. Set by the :class:`Descriptor` constructor if we're passed into one. fields (list[FieldDescriptor]): The list of field descriptors this oneof can contain. Nc Cstjtj|Sr)rrUrVrWZFindOneofByName) rr2rHrrJrYr9r:rar r r rs zOneofDescriptor.__new__c sF|tk rtdtt|||d||_||_||_||_||_ dS)rrZ OneofOptionsN) ror,rrr<r2rHrrJrY) rr2rHrrJrYr9r:rarr r r<s zOneofDescriptor.__init__)NNN)NNN) rrr r rFrrrrr<rr r rr rs rcsJeZdZdZer ejZd ddZd fdd Z ddZ fd d Z Z S) ServiceDescriptoraDescriptor for a service. Attributes: 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 within the .proto file. methods (list[MethodDescriptor]): List of methods provided by this service. methods_by_name (dict(str, MethodDescriptor)): Same :class:`MethodDescriptor` objects as in :attr:`methods_by_name`, but indexed by "name" attribute in each :class:`MethodDescriptor`. options (descriptor_pb2.ServiceOptions): Service options message or None to use default service options. file (FileDescriptor): Reference to file info. Nc Cstjtj|Sr)rrUrVrWZFindServiceByName) rr2rHrmethodsr9r:rIrMrNrar r r r!s zServiceDescriptor.__new__c sh| tk rtdtt|j|d|||d|| |d ||_||_tdd|D|_|jD] } || _ qXdS)NrZServiceOptionsrbcss|]}|j|fVqdSrr1)rfmr r r rh3sz-ServiceDescriptor.__init__..) ror,rrr<rrrpmethods_by_namecontaining_service) rr2rHrrr9r:rIrMrNramethodrr r r<'s$  zServiceDescriptor.__init__cCs|j|dS)zSearches for the specified method, and returns its descriptor. Args: name (str): Name of the method. Returns: MethodDescriptor or None: the desctiptor for the requested method, if found. N)rget)rr2r r r FindMethodByName8s z"ServiceDescriptor.FindMethodByNamecstt||dS)zCopies this to a descriptor_pb2.ServiceDescriptorProto. Args: proto (descriptor_pb2.ServiceDescriptorProto): An empty descriptor proto. N)rrrSrQrr r rSCszServiceDescriptor.CopyToProto)NNNNNN)NNNNNN) rrr r rFrrrrr<rrSrr r rr r s&  rcs6eZdZdZer ejZdddZdfdd Z Z S) MethodDescriptoradDescriptor for a method in a service. Attributes: 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 (Descriptor): The descriptor of the message that this method accepts. output_type (Descriptor): The descriptor of the message that this method returns. options (descriptor_pb2.MethodOptions or None): Method options message, or None to use default method options. Nc Cstjtj|Sr)rrUrVrWr) rr2rHrr input_type output_typer9r:rar r r rbs zMethodDescriptor.__new__c sL| tk rtdtt|||d||_||_||_||_||_ ||_ dS)zThe 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. rZ MethodOptionsN) ror,rrr<r2rHrrrr) rr2rHrrrrr9r:rarr r r<hs zMethodDescriptor.__init__)NNN)NNN) rrr r rFrrrrr<rr r rr rMs rcsBeZdZdZer$ejZd fdd Zd fdd Z ddZ Z S) FileDescriptoraDescriptor for a file. Mimics the descriptor_pb2.FileDescriptorProto. Note that :attr:`enum_types_by_name`, :attr:`extensions_by_name`, and :attr:`dependencies` fields are only set by the :py:mod:`google.protobuf.message_factory` module, and not by the generated proto code. Attributes: name (str): Name of file, relative to root of source tree. package (str): Name of the package syntax (str): string indicating syntax of the file (can be "proto2" or "proto3") serialized_pb (bytes): Byte string of serialized :class:`descriptor_pb2.FileDescriptorProto`. dependencies (list[FileDescriptor]): List of other :class:`FileDescriptor` objects this :class:`FileDescriptor` depends on. public_dependencies (list[FileDescriptor]): A subset of :attr:`dependencies`, which were declared as "public". message_types_by_name (dict(str, Descriptor)): Mapping from message names to their :class:`Desctiptor`. enum_types_by_name (dict(str, EnumDescriptor)): Mapping from enum names to their :class:`EnumDescriptor`. extensions_by_name (dict(str, FieldDescriptor)): Mapping from extension names declared at file scope to their :class:`FieldDescriptor`. services_by_name (dict(str, ServiceDescriptor)): Mapping from services' names to their :class:`ServiceDescriptor`. pool (DescriptorPool): The pool this descriptor belongs to. When not passed to the constructor, the global default pool is used. Nc s^|dkr:ztj|WStk r6td|YqZXn |rJtj|Stt||SdS)Nz'Please link in cpp generated lib for %s) rrWFindFileByNamerrCZAddSerializedFilerrr) rr2packager9r:rP dependenciespublic_dependenciesr`poolrarr r rs zFileDescriptor.__new__c s| tk rtdtt|||d| dkr@ddlm} | } | |_i|_ ||_ ||_ |p^d|_ ||_ i|_i|_i|_|pg|_|pg|_dS)z Constructor.rZ FileOptionsNr)descriptor_poolrn)ror,rrr<r@rZDefaultrmessage_types_by_namer2rr`rPrrrtZservices_by_namerr) rr2rr9r:rPrrr`rrarrr r r<s*    zFileDescriptor.__init__cCs||jdS)z~Copies this to a descriptor_pb2.FileDescriptorProto. Args: proto: An empty descriptor_pb2.FileDescriptorProto. N)rOrPrQr r r rSszFileDescriptor.CopyToProto)NNNNNNNN)NNNNNNNN) rrr r rFrrrrr<rSrr r rr r}s,rcCs|||S)zParses serialized options. This helper function is used to parse serialized options in generated proto2 files. It must not be used outside proto2. )rO)messagestringr r r rDs rDcCsnd}g}|D]6}|dkr"|rBd}q |r:||d}q ||7}q |rd|drd|d|d<d|S)z+Converts name to camel-case and returns it.F_Tr)appendupperisupperlowerjoinr2Zcapitalize_nextresultcr r r rs rcCs|dr|jSdSdS)zCReturns the value of the field `options`, or None if it is not set.r9N)HasFieldr9)Zdescriptor_protor r r _OptionsOrNones rcCsJd}g}|D]2}|dkrd}q |r6||d}q ||7}q d|S)z*Converts name to Json name and returns it.FrTr)rrrrr r r rs rrcCsrtdkr|rddlm}|}|j|t t d d}|rrt j |dd|d|_||_n |d|_tj|tj|j}tr|j|jS|jg}|r|d|i} |jD]B} d|| jg} t| j| d d d t| jDtd } | | | <qi} |jD]6}d||jg} t|d|d |d}|| | <qg}|j D]}d||jg} d } d }|j!r|j!}nd }|"dr|j#}d|||$ddd g}|| kr| |}n|| kr| |} t%|j| |j&d|j&|j't%(|j'|j)d || d d d t*|d |td}|+|qXd|}t,|j|d d |t-| .t-| .gt*|td S)aMake a protobuf Descriptor given a DescriptorProto protobuf. Handles nested descriptors. Note that this is limited to the scope of defining a message inside of another message. Composite fields can currently only be resolved if the message is defined in the same scope as the field. Args: desc_proto: The descriptor_pb2.DescriptorProto protobuf message. package: Optional package name for the new message Descriptor (string). build_file_if_cpp: Update the C++ descriptor pool if api matches. Set to False on recursion, so no duplicates are created. syntax: The syntax/semantics that should be used. Set to "proto3" to get proto3 field presence semantics. Returns: A Descriptor for protobuf messages. rrr>rascii./z.protoNcSs$g|]\}}t|j||jtdqS)ra)rr2rdro)rfiiZenum_valr r r Cs z"MakeDescriptor..rF)rbuild_file_if_cppr` type_namer()r9rrra)r9ra)/rrr@r?ZFileDescriptorProtoraddZ MergeFrombinasciihexlifyosurandomdecodepathrreplacer2rrrWZAddrrFrinsertrwr enumerater}rorvMakeDescriptorrurrrrfindrrdrrrrrrTlistrk)Z desc_protorrr`r?Zfile_descriptor_protoZ proto_namerZfull_message_namer[Z enum_protorHZ enum_descrZZ nested_protoZ nested_descrYZ field_protorrZfull_type_nameruZ desc_namer r r r s                 r)rTN))r __author__rr.sixZgoogle.protobuf.internalrrFrrrZgoogle.protobuf.pyextr Exceptionrr rrrrrrr,r-rowith_metaclassr4rGrTrrrrrrrrDrrrrr r r r sP     G8&^D,(B0X