B @`1@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 >/tmp/pip-unpacked-wheel-3chbcimp/google/protobuf/descriptor.pyr4src@seZdZdZdS)TypeTransformationErrorzHError transforming between python proto type and corresponding C++ type.N)rrrr r 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__)rrrr __classcell__r r )rr r Asr c@s(eZdZdZddZddZddZdS) _Lockz>Wrapper class of threading.Lock(), which is allowed by 'with'.cCst|}t|_|S)N)object__new__ threadingLock_lock)rselfr r r rPs  z _Lock.__new__cCs|jdS)N)racquire)rr r r __enter__Usz_Lock.__enter__cCs|jdS)N)rrelease)rexc_type exc_valueexc_tbr r r __exit__Xsz_Lock.__exit__N)rrrr rrr#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) _DeprecatedcountwarningswarnDeprecationWarning)namer 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)r0r1r3)rr4r6r r r _SetOptionsszDescriptorBase._SetOptionsc Cs|jr |jSddlm}yt||j}Wn"tk rJtd|jYnXt,|jdkrf||_nt ||j|_|jSQRXdS)zRetrieves descriptor options. This method returns the options set or creates the default options for the descriptor. r)descriptor_pb2zUnknown options class name %s!N) r0google.protobufr9getattrr1AttributeError RuntimeErrorrr2 _ParseOptions)rr9Z options_classr r r GetOptionss     zDescriptorBase.GetOptionsN) rrrr _USE_C_DESCRIPTORSrr7r8r?r r r r r/rs    r/cs*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) rrAr7r- full_namefilecontaining_type_serialized_start_serialized_end) rr4r6r-rBrCrDserialized_startserialized_endr5)rr r r7s  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 couldn't be serialized, due to to few constructor arguments. Nz*Descriptor does not contain serialization.)rCrErFParseFromString serialized_pbr)rprotor r r CopyToProtos    z!_NestedDescriptorBase.CopyToProto)NNN)rrrr r7rLrr r )rr rAs!rAc 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|S)N)rMessage_CheckCalledFromGeneratedFile default_poolZFindMessageTypeByName)rr-rBfilenamerDfields nested_types enum_types extensionsr4r5 is_extendableextension_rangesoneofsrCrGrHsyntax create_keyr r r r"s zDescriptor.__new__c s||tk rtdtt|j| d||||||| d ||_x|jD] }||_q@Wtdd|D|_tdd|D|_ d|_ ||_ x|D] }||_qWtdd|D|_ ||_ x|j D] }||_qWtd d|D|_td d|D|_||_x|jD] }||_qWtd d|D|_| |_| |_| dk r8| ng|_td d|jD|_x|jD] }||_q\W|ptd |_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. rMZMessageOptions)rGrHr5css|]}|j|fVqdS)N)number).0fr r r Jsz&Descriptor.__init__..css|]}|j|fVqdS)N)r-)r\r]r r r r^KsNcss|]}|j|fVqdS)N)r-)r\tr r r r^Qscss|]}|j|fVqdS)N)r-)r\r_r r r r^Vscss$|]}|jD]}|j|fVq qdS)N)valuesr-)r\r_vr r r r^Xscss|]}|j|fVqdS)N)r-)r\r]r r r r^]scss|]}|j|fVqdS)N)r-)r\or r r r^asproto2)_internal_create_keyr(rrMr7rRrDdictZfields_by_numberZfields_by_name_fields_by_camelcase_namerSZnested_types_by_namerTenum_types_by_nameZenum_values_by_namerUextension_scopeextensions_by_namerVrWrXZoneofs_by_namerY)rr-rBrQrDrRrSrTrUr4r5rVrWrXrCrGrHrYrZfield nested_type enum_type extensionZoneof)rr r r7.sB              zDescriptor.__init__cCs&|jdkr tdd|jD|_|jS)zrSame FieldDescriptor objects as in :attr:`fields`, but indexed by :attr:`FieldDescriptor.camelcase_name`. Ncss|]}|j|fVqdS)N)camelcase_name)r\r]r r r r^msz6Descriptor.fields_by_camelcase_name..)rfrerR)rr r r fields_by_camelcase_namefs 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. )rgvalues_by_numberr-)renumvaluer r r EnumValueNamepszDescriptor.EnumValueNamecstt||dS)zvCopies this to a descriptor_pb2.DescriptorProto. Args: proto: An empty descriptor_pb2.DescriptorProto. N)rrMrL)rrK)rr r rLszDescriptor.CopyToProto) NNTNNNNNNN) NNTNNNNNNN)rrrr r@rrMrrr7propertyrorsrLrr r )rr rMs + 3 rMc$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|SdS)N)rrNrOrPFindExtensionByNameFindFieldByName)rr-rBindexr[typecpp_typelabel default_value message_typerlrD is_extensionrhr4r5has_default_valuecontaining_oneof json_namerCrZr 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. ruZ FieldOptionsNr)rdr(rrur7r-rBrC_camelcase_name _ToJsonNamerrr[rrrrrrDrrlrrhrrTyperrPrZ _cdescriptorr)rr-rBrr[rrrrrrlrDrrhr4r5rrrrCrZ)rr r r7%s:     zFieldDescriptor.__init__cCs|jdkrt|j|_|jS)zRCamelcase name of this field. Returns: str: the name in CamelCase. N)r _ToCamelCaser-)rr r r rnTs  zFieldDescriptor.camelcase_namecCs0y tj|Stk 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)ru_PYTHON_TO_CPP_PROTO_TYPE_MAPKeyErrorr )Z proto_typer r r ProtoTypeToCppProtoType_s z'FieldDescriptor.ProtoTypeToCppProtoType)NNTNNNN)NNTNNNN)5rrrr 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_NUMBERr@rrurrr7rtrn staticmethodrrr r )rr rus1 * rucsBeZdZdZer 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|S)N)rrNrOrPZFindEnumTypeByName) rr-rBrQr`rDr4r5rCrGrHrZr r r rs zEnumDescriptor.__new__c s~| tk rtdtt|j|d||||| | |d ||_x|jD] } || _q@Wtdd|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 EnumOptions)rGrHr5css|]}|j|fVqdS)N)r-)r\rar r r r^sz*EnumDescriptor.__init__..css|]}|j|fVqdS)N)r[)r\rar r r r^sN) rdr(rrr7r`rreZvalues_by_namereversedrp) rr-rBrQr`rDr4r5rCrGrHrZrr)rr r r7s      zEnumDescriptor.__init__cstt||dS)zCopies this to a descriptor_pb2.EnumDescriptorProto. Args: proto (descriptor_pb2.EnumDescriptorProto): An empty descriptor proto. N)rrrL)rrK)rr r rLszEnumDescriptor.CopyToProto)NNNNNNN)NNNNNNN) rrrr r@rrrrr7rLrr r )rr rts 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. NcCstjdS)N)rrNrO)rr-rr[rr4r5rZr r r rs zEnumValueDescriptor.__new__cs@|tk rtdtt|||d||_||_||_||_dS)z>Arguments are as described in the attribute description above.rZEnumValueOptionsN) rdr(rrr7r-rr[r)rr-rr[rr4r5rZ)rr r r7s  zEnumValueDescriptor.__init__)NNNN)NNNN) rrrr r@rrrrr7rr 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|S)N)rrNrOrPZFindOneofByName) rr-rBrrDrRr4r5rZr r r rs zOneofDescriptor.__new__c sF|tk rtdtt|||d||_||_||_||_||_ dS)z>Arguments are as described in the attribute description above.rZ OneofOptionsN) rdr(rrr7r-rBrrDrR) rr-rBrrDrRr4r5rZ)rr r r7s  zOneofDescriptor.__init__)NNN)NNN) rrrr r@rrrrr7rr 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|S)N)rrNrOrPZFindServiceByName) rr-rBrmethodsr4r5rCrGrHrZr r r r"s zServiceDescriptor.__new__c sl| tk rtdtt|j|d|||d|| |d ||_||_tdd|D|_x|jD] } || _ qZWdS)NrZServiceOptions)rGrHr5css|]}|j|fVqdS)N)r-)r\mr r r r^4sz-ServiceDescriptor.__init__..) rdr(rrr7rrremethods_by_namecontaining_service) rr-rBrrr4r5rCrGrHrZmethod)rr r r7(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 descriptor for the requested method, if found. N)rget)rr-r r r FindMethodByName9s z"ServiceDescriptor.FindMethodByNamecstt||dS)zCopies this to a descriptor_pb2.ServiceDescriptorProto. Args: proto (descriptor_pb2.ServiceDescriptorProto): An empty descriptor proto. N)rrrL)rrK)rr r rLDszServiceDescriptor.CopyToProto)NNNNNN)NNNNNN) rrrr r@rrrrr7rrLrr 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|S)N)rrNrOrPr) rr-rBrr input_type output_typer4r5rZr r r rcs 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) rdr(rrr7r-rBrrrr) rr-rBrrrrr4r5rZ)rr r r7is  zMethodDescriptor.__init__)NNN)NNN) rrrr r@rrrrr7rr r )rr rNs 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\|dkr8y tj|Stk r4td|YqXXn |rHtj|Stt||SdS)Nz'Please link in cpp generated lib for %s) rrPFindFileByNamerr=ZAddSerializedFilerrr) rr-packager4r5rJ dependenciespublic_dependenciesrYpoolrZ)rr 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_poolrc)rdr(rrr7r:rZDefaultrmessage_types_by_namer-rrYrJrgriZservices_by_namerr) rr-rr4r5rJrrrYrrZr)rr r r7s$     zFileDescriptor.__init__cCs||jdS)z~Copies this to a descriptor_pb2.FileDescriptorProto. Args: proto: An empty descriptor_pb2.FileDescriptorProto. N)rIrJ)rrKr r r rLszFileDescriptor.CopyToProto)NNNNNNNN)NNNNNNNN) rrrr r@rrrrr7rLrr r )rr r~srcCs|||S)zParses serialized options. This helper function is used to parse serialized options in generated proto2 files. It must not be used outside proto2. )rI)messagestringr r r r>s r>cCsrd}g}x>|D]6}|dkr$|rDd}q|r<||d}q||7}qW|rh|drh|d|d<d|S)z+Converts name to camel-case and returns it.F_Tr)appendupperisupperlowerjoin)r-capitalize_nextresultcr r r rs  rcCs|dr|jSdSdS)zCReturns the value of the field `options`, or None if it is not set.r4N)HasFieldr4)Zdescriptor_protor r r _OptionsOrNones rcCsNd}g}x:|D]2}|dkr d}q|r8||d}q||7}qWd|S)z*Converts name to Json name and returns it.FrTr)rrr)r-rrrr r r rs  rrcCs~tdkr|rddlm}|}|j|t t d d}|rrt j |dd|d|_||_n |d|_tj|tj|j}tr|j|jS|jg}|r|d|i} xL|jD]B} d|| jg} t| j| d d d t| jDtd } | | | <qWi} x@|jD]6}d||jg} t|d|d |d}|| | <qWg}x|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}|+|qbWd|}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. rr)r9rascii./z.protoNcSs$g|]\}}t|j||jtdqS))rZ)rr-r[rd)r\iiZenum_valr r r Esz"MakeDescriptor..)rZF)rbuild_file_if_cpprY type_namer$)r4rrrZ)r4rZ)/rrr:r9ZFileDescriptorProtoraddZ MergeFrombinasciihexlifyosurandomdecodepathrreplacer-rrrPZAddrr@rinsertrlr enumeraterrrdrkMakeDescriptorrjrrrrfindrur[rrrrrrMlistr`)Z desc_protorrrYr9Zfile_descriptor_protoZ proto_namerZfull_message_namerTZ enum_protorBZ enum_descrSZ nested_protoZ nested_descrRZ field_protorrZfull_type_namerjZ desc_namer r r rs~                  r)rTN))r __author__rr*sixZgoogle.protobuf.internalrr@rrrZgoogle.protobuf.pyextr Exceptionrr rr rrrrr(r)rdwith_metaclassr/rArMrurrrrrrr>rrrrr r r r !sN     G9&^D,(B0X