o
    {j6h                     @   s  d Z dZddlZddlZddlZddlZddlZddlmZ dZ	e
 dkr5ejZedu r3ddlmZ dZ	G d	d
 d
eZG dd deZe	rPG dd deZnejZG dd deZe Zdd ZdZdZdZdZdZde_e ZG dd dedZ G dd de Z!G dd de!Z"G dd de Z#G d d! d!e!Z$G d"d# d#e Z%G d$d% d%e Z&G d&d' d'e!Z'G d(d) d)e Z(G d*d+ d+e Z)d,d- Z*d.d/ Z+d0d1 Z,d2d3 Z-	4				d7d5d6Z.dS )8zDescriptors 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_implementationFpython)_messageTc                   @      e Zd ZdZdS )ErrorzBase error for this module.N__name__
__module____qualname____doc__ r   r   i/var/www/html/chefvision.cloud.itp360.com/venv/lib/python3.10/site-packages/google/protobuf/descriptor.pyr           r   c                   @   r   )TypeTransformationErrorzHError transforming between python proto type and corresponding C++ type.Nr   r   r   r   r   r   $   r   r   c                       s   e Zd Z fddZ  ZS )DescriptorMetaclassc                    s(   t t| |r
dS t|| jrdS dS )NTF)superr   __instancecheck__
isinstance_C_DESCRIPTOR_CLASS)clsobj	__class__r   r   r   /   s
   z%DescriptorMetaclass.__instancecheck__)r   r	   r
   r   __classcell__r   r   r   r   r   -   s    r   c                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )	_Lockz>Wrapper class of threading.Lock(), which is allowed by 'with'.c                 C   s   t | }t |_|S N)object__new__	threadingLock_lock)r   selfr   r   r   r   =   s   

z_Lock.__new__c                 C      | j   d S r   )r    acquirer!   r   r   r   	__enter__B      z_Lock.__enter__c                 C   r"   r   )r    release)r!   exc_type	exc_valueexc_tbr   r   r   __exit__E   r&   z_Lock.__exit__N)r   r	   r
   r   r   r%   r+   r   r   r   r   r   :   s
    r   c                 C   s4   t jdkrt  jd8  _tjd|  tdd d S d S )Nr      zCall 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)_DeprecatedcountwarningswarnDeprecationWarningnamer   r   r   r0   L   s   

r0      r-   r,   d   c                   @   sZ   e Zd ZdZer
dZdd Zeej	dd Z
dd Zd	d
 Zdd Zdd Zdd ZdS )DescriptorBasea  Descriptors 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.
    file (FileDescriptor): Reference to file info.
  r   c                 C   s>   d| _ || _|| _d| _|| _|| _| jdup| jdu| _dS )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)	_featuresfile_options_loaded_options_options_class_name_serialized_optionshas_options)r!   r;   optionsserialized_optionsoptions_class_namer   r   r   __init__|   s   
zDescriptorBase.__init__c                 C      d S r   r   r$   r   r   r   _parent   s   zDescriptorBase._parentc                 C   s   dS )a,  Infers features from proto2/proto3 syntax so that editions logic can be used everywhere.

    Args:
      edition: The edition to infer features for.
      options: The options for this descriptor that are being processed.
      features: The feature set object to modify with inferred features.
    Nr   )r!   editionrA   featuresr   r   r   _InferLegacyFeatures   s   z#DescriptorBase._InferLegacyFeaturesc                 C      | j s|   | j S r   )r:   _LazyLoadOptionsr$   r   r   r   _GetFeatures   s   zDescriptorBase._GetFeaturesc                 C   st   ddl m} | jr| }|| j  n| jj|}| }||j	 | 
||| || | jj|S )a  Resolves features from the raw options of this descriptor.

    Args:
      edition: The edition to use for feature defaults.
      raw_options: The options for this descriptor that are being processed.

    Returns:
      A fully resolved feature set for making runtime decisions.
    r   descriptor_pb2)google.protobufrN   rF   
FeatureSetCopyFromrL   r;   pool_CreateDefaultFeaturesrH   rI   	MergeFrom_InternFeatures)r!   rG   raw_optionsrN   rH   
unresolvedr   r   r   _ResolveFeatures   s   
zDescriptorBase._ResolveFeaturesc                 C   st  | j rdS ddlm} t|| jstd| j t|| j}d}| jj}| j	s\| j
s5| |j|| }t | | _ | j
sJ|| _
W d   dS W d   dS 1 sUw   Y  dS | jsc| j}nt| | j}| j
sw| |j||}t7 || _ | j
s|| _
|dr|d | s| | _ d| _	W d   dS W d   dS W d   dS 1 sw   Y  dS )zCLazily initializes descriptor options towards the end of the build.Nr   rM   zUnknown options class name %s!rH   F)r=   rO   rN   hasattrr>   RuntimeErrorgetattrr;   _editionr@   r:   rX   EditionValuer    r?   r<   _ParseOptionsHasField
ClearFieldSerializeToString)r!   rN   options_classrH   rG   rA   r   r   r   rK      sV   "

"zDescriptorBase._LazyLoadOptionsc                 C   rJ   )zZRetrieves descriptor options.

    Returns:
      The options set on this descriptor.
    )r=   rK   r$   r   r   r   
GetOptions   s   zDescriptorBase.GetOptionsN)r   r	   r
   r   _USE_C_DESCRIPTORSr   rD   propertyabcabstractmethodrF   rI   rL   rX   rK   rd   r   r   r   r   r9   g   s    
-r9   )	metaclassc                       s.   e Zd ZdZ		d fdd	Zdd Z  ZS )_NestedDescriptorBasez0Common class for descriptors that can be nested.Nc
           
         s8   t t| |||	| || _|| _|| _|| _|| _dS )aL  Constructor.

    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.
      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)r   rj   rD   r6   	full_namecontaining_type_serialized_start_serialized_end)
r!   rA   rC   r6   rk   r;   rl   serialized_startserialized_endrB   r   r   r   rD      s   

z_NestedDescriptorBase.__init__c                 C   sD   | j dur| jdur| jdur|| j j| j| j  dS td)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.)r;   rm   rn   ParseFromStringserialized_pbr   r!   protor   r   r   CopyToProto  s   






z!_NestedDescriptorBase.CopyToProtoNNN)r   r	   r
   r   rD   ru   r   r   r   r   r   rj      s    !rj   c                       s   e Zd ZdZer#ejZ																			dddZ					d fdd	Z	e
d	d
 Ze
dd Zdd Z fddZ  ZS )
Descriptorau	  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.
      is_map_entry: If the message type is a map entry.

  NTFc                 C      t j  t j|S r   )r   Message_CheckCalledFromGeneratedFiledefault_poolFindMessageTypeByName)r   r6   rk   filenamerl   fieldsnested_types
enum_types
extensionsrA   rB   is_extendableextension_rangesoneofsr;   ro   rp   syntaxis_map_entry
create_keyr   r   r   r   [  s   
zDescriptor.__new__c                    sj  |t urtd tt| j|	d|||||||
d	 || _| jD ]}| |_||_qtdd |D | _	tdd |D | _
d| _|| _|D ]}| |_qDtdd |D | _|| _| jD ]}| |_qZtd	d |D | _td
d |D | _|| _| jD ]}| |_qztdd |D | _|| _|| _|dur|ng | _tdd | jD | _| jD ]}| |_||_q|| _dS )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.
    rw   MessageOptionsro   rp   rB   c                 s       | ]}|j |fV  qd S r   number.0fr   r   r   	<genexpr>      z&Descriptor.__init__.<locals>.<genexpr>c                 s   r   r   r5   r   r   r   r   r     r   Nc                 s   r   r   r5   r   tr   r   r   r     r   c                 s   r   r   r5   r   r   r   r   r     r   c                 s   s&    | ]}|j D ]}|j|fV  qqd S r   )valuesr6   )r   r   vr   r   r   r     s    
c                 s   r   r   r5   r   r   r   r   r     r   c                 s   r   r   r5   )r   or   r   r   r     r   )_internal_create_keyr0   r   rw   rD   r~   rl   r;   dictfields_by_numberfields_by_name_fields_by_camelcase_namer   nested_types_by_namer   enum_types_by_nameenum_values_by_namer   extension_scopeextensions_by_namer   r   r   oneofs_by_name_is_map_entry)r!   r6   rk   r}   rl   r~   r   r   r   rA   rB   r   r   r   r;   ro   rp   r   r   r   fieldnested_type	enum_type	extensiononeofr   r   r   rD   v  sJ   








zDescriptor.__init__c                 C      | j p| jS r   rl   r;   r$   r   r   r   rF        zDescriptor._parentc                 C   s&   | j du rtdd | jD | _ | j S )zrSame FieldDescriptor objects as in :attr:`fields`, but indexed by
    :attr:`FieldDescriptor.camelcase_name`.
    Nc                 s   r   r   )camelcase_namer   r   r   r   r     s    

z6Descriptor.fields_by_camelcase_name.<locals>.<genexpr>)r   r   r~   r$   r   r   r   fields_by_camelcase_name  s
   

z#Descriptor.fields_by_camelcase_namec                 C   s   | j | j| jS )as  Returns 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.
    )r   values_by_numberr6   )r!   enumvaluer   r   r   EnumValueName  s   zDescriptor.EnumValueNamec                       t t| | dS )zvCopies this to a descriptor_pb2.DescriptorProto.

    Args:
      proto: An empty descriptor_pb2.DescriptorProto.
    N)r   rw   ru   rs   r   r   r   ru        zDescriptor.CopyToProto)NNNNNNNNNNTNNNNNNFN)NNTNNNNNNFN)r   r	   r
   r   re   r   rw   r   r   rD   rf   rF   r   r   ru   r   r   r   r   r   rw   *  sH    ,
:

	rw   c                       s  e 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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Z!i eeeeeeeeeeeeeee	eeeeeeeeee
eeeeeeeee ee iZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)e*re+j,Z-				d.ddZ.				d. fdd	Z/e0dd Z1dd  Z2e0d!d" Z3e3j4d#d" Z3e0d$d% Z5e0d&d' Z6e0d(d) Z7e0d*d+ Z8e9d,d- Z:  Z;S )/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,   r7   r-                  	   
                           ii8J  iN  NTc                 C   s&   t j  |rt j|S t j|S r   )r   ry   rz   r{   FindExtensionByNameFindFieldByName)r   r6   rk   indexr   typecpp_typelabeldefault_valuemessage_typer   rl   is_extensionr   rA   rB   has_default_valuecontaining_oneof	json_namer;   r   r   r   r   r   g  s   
zFieldDescriptor.__new__c                    s   |t urtd tt| |||d || _|| _d| _|du r&t|| _	n|| _	|| _
|| _|| _|| _|| _|| _|| _|| _|	| _|
| _|| _|| _|| _t dkr[d| _dS |rftj|| _dS tj|| _dS )a  The 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.
    r   FieldOptionsNr   )r   r0   r   r   rD   r6   rk   _camelcase_name_ToJsonNamer   r   r   _typer   _labelr   r   rl   r   r   r   r   r   r   Type_cdescriptorr   r{   r   r   )r!   r6   rk   r   r   r   r   r   r   r   r   rl   r   r   rA   rB   r   r   r   r;   r   r   r   r   rD   s  s:   

zFieldDescriptor.__init__c                 C   s$   | j r| j S | jr| jp| jS | jS r   )r   r   r   r;   rl   r$   r   r   r   rF     s
   zFieldDescriptor._parentc                 C   sz   ddl m} ||jjkrd S | jtjkr|jjj	|_
| jtjkr&|jjj|_|dr;|jr3|jjjn|jjj|_d S d S )Nr   rM   packed)rO   rN   r]   EDITION_2023r   r   LABEL_REQUIREDrP   FieldPresenceLEGACY_REQUIREDfield_presencer   
TYPE_GROUPMessageEncoding	DELIMITEDmessage_encodingr`   r   RepeatedFieldEncodingPACKEDEXPANDEDrepeated_field_encoding)r!   rG   rA   rH   rN   r   r   r   rI     s   
z$FieldDescriptor._InferLegacyFeaturesc                 C   s8   |   jtkr| jr| j js| j jstjS | j	S r   )
rL   r   &_FEATURESET_MESSAGE_ENCODING_DELIMITEDr   rd   	map_entryrl   r   r   r   r$   r   r   r   r     s   

zFieldDescriptor.typec                 C   s
   || _ d S r   )r   )r!   valr   r   r   r     s   
c                 C   s   |   jtkr
tjS | jS r   )rL   r   *_FEATURESET_FIELD_PRESENCE_LEGACY_REQUIREDr   r   r   r$   r   r   r   r     s
   zFieldDescriptor.labelc                 C   s   | j du rt| j| _ | j S )zRCamelcase name of this field.

    Returns:
      str: the name in CamelCase.
    N)r   _ToCamelCaser6   r$   r   r   r   r     s   
zFieldDescriptor.camelcase_namec                 C   s:   | j tjkrdS | jtjks| js| jrdS |  jt	kS )zWhether the field distinguishes between unpopulated and default values.

    Raises:
      RuntimeError: singular field that is not linked with message nor file.
    FT)
r   r   LABEL_REPEATEDr   CPPTYPE_MESSAGEr   r   rL   r   #_FEATURESET_FIELD_PRESENCE_IMPLICITr$   r   r   r   has_presence  s   zFieldDescriptor.has_presencec                 C   sP   | j tjkrdS | j}|tjks|tjks|tjks|tjkr!dS |  j	t
kS )zReturns if the field is packed.F)r   r   r   r   TYPE_STRINGr   TYPE_MESSAGE
TYPE_BYTESrL   r   *_FEATURESET_REPEATED_FIELD_ENCODING_PACKED)r!   
field_typer   r   r   	is_packed  s   



zFieldDescriptor.is_packedc                 C   s(   zt j|  W S  ty   td|  w )a  Converts 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.
    zUnknown proto_type: %s)r   _PYTHON_TO_CPP_PROTO_TYPE_MAPKeyErrorr   )
proto_typer   r   r   ProtoTypeToCppProtoType  s
   z'FieldDescriptor.ProtoTypeToCppProtoType)NNTNNNN)<r   r	   r
   r   TYPE_DOUBLE
TYPE_FLOAT
TYPE_INT64TYPE_UINT64
TYPE_INT32TYPE_FIXED64TYPE_FIXED32	TYPE_BOOLr   r   r   r   TYPE_UINT32	TYPE_ENUMTYPE_SFIXED32TYPE_SFIXED64TYPE_SINT32TYPE_SINT64MAX_TYPECPPTYPE_INT32CPPTYPE_INT64CPPTYPE_UINT32CPPTYPE_UINT64CPPTYPE_DOUBLECPPTYPE_FLOATCPPTYPE_BOOLCPPTYPE_ENUMCPPTYPE_STRINGr   MAX_CPPTYPEr   LABEL_OPTIONALr   r   	MAX_LABELMAX_FIELD_NUMBERFIRST_RESERVED_FIELD_NUMBERLAST_RESERVED_FIELD_NUMBERre   r   r   r   r   rD   rf   rF   rI   r   setterr   r   r   r   staticmethodr   r   r   r   r   r   r     s    5	

/







r   c                       sf   e Zd ZdZerejZ			dddZ			d fdd	Z	e
dd Ze
d	d
 Z fddZ  ZS )EnumDescriptora  Descriptor 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[EnumValueDescriptor]): 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                 C   rx   r   )r   ry   rz   r{   FindEnumTypeByName)r   r6   rk   r}   r   rl   rA   rB   r;   ro   rp   r   r   r   r   r   <  s   
zEnumDescriptor.__new__c                    s   |t urtd tt| j|d|||||	|
|d	 || _| jD ]}||_| |_qtdd |D | _	tdd t
|D | _dS )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.
    r  EnumOptionsr   c                 s   r   r   r5   r   r   r   r   r   r   X  r   z*EnumDescriptor.__init__.<locals>.<genexpr>c                 s   r   r   r   r  r   r   r   r   Z  r   N)r   r0   r   r  rD   r   r;   r   r   values_by_namereversedr   )r!   r6   rk   r}   r   rl   rA   rB   r;   ro   rp   r   r   r   r   r   rD   C  s   	


zEnumDescriptor.__init__c                 C   r   r   r   r$   r   r   r   rF   \  r   zEnumDescriptor._parentc                 C   s   |   jtkS )a:  Returns true whether this is a "closed" enum.

    This means that it:
    - Has a fixed set of values, rather than being equivalent to an int32.
    - Encountering values not in this set causes them to be treated as unknown
      fields.
    - The first value (i.e., the default) may be nonzero.

    WARNING: Some runtimes currently have a quirk where non-closed enums are
    treated as closed when used as the type of fields defined in a
    `syntax = proto2;` file. This quirk is not present in all runtimes; as of
    writing, we know that:

    - C++, Java, and C++-based Python share this quirk.
    - UPB and UPB-based Python do not.
    - PHP and Ruby treat all enums as open regardless of declaration.

    Care should be taken when using this function to respect the target
    runtime's enum handling quirks.
    )rL   r   _FEATURESET_ENUM_TYPE_CLOSEDr$   r   r   r   	is_closed`  s   zEnumDescriptor.is_closedc                    r   )zCopies this to a descriptor_pb2.EnumDescriptorProto.

    Args:
      proto (descriptor_pb2.EnumDescriptorProto): An empty descriptor proto.
    N)r   r  ru   rs   r   r   r   ru   x  r   zEnumDescriptor.CopyToProto)NNNNNNN)r   r	   r
   r   re   r   r  r   r   rD   rf   rF   r  ru   r   r   r   r   r   r  !  s"    


r  c                       J   e Zd ZdZerejZ		d	ddZ		d	 fdd	Z	e
dd Z  ZS )
EnumValueDescriptoraL  Descriptor 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.
  Nc                 C   s   t j  d S r   )r   ry   rz   )r   r6   r   r   r   rA   rB   r   r   r   r   r     s   
zEnumValueDescriptor.__new__c                    sL   |t urtd tt| |r|jnd||d || _|| _|| _|| _	dS )>Arguments are as described in the attribute description above.r   NEnumValueOptions)
r   r0   r   r   rD   r;   r6   r   r   r   )r!   r6   r   r   r   rA   rB   r   r   r   r   rD     s   

zEnumValueDescriptor.__init__c                 C      | j S r   )r   r$   r   r   r   rF        zEnumValueDescriptor._parent)NNNN)r   r	   r
   r   re   r   r   r   r   rD   rf   rF   r   r   r   r   r   r     s    
r   c                       r  )
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	           	      C   rx   r   )r   ry   rz   r{   FindOneofByName)	r   r6   rk   r   rl   r~   rA   rB   r   r   r   r   r     s   
zOneofDescriptor.__new__c	           	         sR   |t urtd tt| |r|jnd||d || _|| _|| _|| _	|| _
dS )r!  r%  NOneofOptions)r   r0   r   r%  rD   r;   r6   rk   r   rl   r~   )	r!   r6   rk   r   rl   r~   rA   rB   r   r   r   r   rD     s   

zOneofDescriptor.__init__c                 C   r#  r   )rl   r$   r   r   r   rF     r$  zOneofDescriptor._parentrv   )r   r	   r
   r   re   r   r%  r   r   rD   rf   rF   r   r   r   r   r   r%    s    
r%  c                       sp   e Zd ZdZerejZ										dddZ			d fdd	Z	e
dd Zd	d
 Z fddZ  ZS )ServiceDescriptora  Descriptor 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                 C   rx   r   )r   ry   rz   r{   FindServiceByName)r   r6   rk   r   methodsrA   rB   r;   ro   rp   r   r   r   r   r        
zServiceDescriptor.__new__c                    sp   |
t urtd tt| j|d|||d ||	|d	 || _|| _tdd |D | _| jD ]	}| j	|_	| |_
q,d S )Nr(  ServiceOptionsr   c                 s   r   r   r5   )r   mr   r   r   r     r   z-ServiceDescriptor.__init__.<locals>.<genexpr>)r   r0   r   r(  rD   r   r*  r   methods_by_namer;   containing_service)r!   r6   rk   r   r*  rA   rB   r;   ro   rp   r   methodr   r   r   rD     s   


zServiceDescriptor.__init__c                 C   r#  r   )r;   r$   r   r   r   rF     r$  zServiceDescriptor._parentc                 C   s
   | j | S )a  Searches for the specified method, and returns its descriptor.

    Args:
      name (str): Name of the method.

    Returns:
      MethodDescriptor: The descriptor for the requested method.

    Raises:
      KeyError: if the method cannot be found in the service.
    )r.  )r!   r6   r   r   r   FindMethodByName!  s   
z"ServiceDescriptor.FindMethodByNamec                    r   )zCopies this to a descriptor_pb2.ServiceDescriptorProto.

    Args:
      proto (descriptor_pb2.ServiceDescriptorProto): An empty descriptor proto.
    N)r   r(  ru   rs   r   r   r   ru   /  r   zServiceDescriptor.CopyToProto)
NNNNNNNNNN)NNNNNN)r   r	   r
   r   re   r   r(  r   r   rD   rf   rF   r1  ru   r   r   r   r   r   r(    s.    

r(  c                       s^   e Zd ZdZerejZ					dddZ					d fdd	Z	e
dd	 Zd
d Z  ZS )MethodDescriptora  Descriptor 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.
    client_streaming (bool): Whether this method uses client streaming.
    server_streaming (bool): Whether this method uses server streaming.
    options (descriptor_pb2.MethodOptions or None): Method options message, or
      None to use default method options.
  FNc                 C   rx   r   )r   ry   rz   r{   r1  )r   r6   rk   r   r/  
input_typeoutput_typeclient_streamingserver_streamingrA   rB   r   r   r   r   r   P  r+  zMethodDescriptor.__new__c                    sd   |t urtd tt| |r|jnd|	|
d || _|| _|| _|| _	|| _
|| _|| _|| _dS )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.
    r2  NMethodOptions)r   r0   r   r2  rD   r;   r6   rk   r   r/  r3  r4  r5  r6  )r!   r6   rk   r   r/  r3  r4  r5  r6  rA   rB   r   r   r   r   rD   _  s    

zMethodDescriptor.__init__c                 C   r#  r   )r/  r$   r   r   r   rF     r$  zMethodDescriptor._parentc                 C   sH   | j dur ddlm} | }| j | ||j| j  dS td)zCopies this to a descriptor_pb2.MethodDescriptorProto.

    Args:
      proto (descriptor_pb2.MethodDescriptorProto): An empty descriptor proto.

    Raises:
      Error: If self couldn't be serialized, due to too few constructor
        arguments.
    Nr   rM   z&Descriptor does not contain a service.)	r/  rO   rN   ServiceDescriptorProtoru   rQ   r0  r   r   )r!   rt   rN   service_protor   r   r   ru     s   

zMethodDescriptor.CopyToProto)FFNNN)r   r	   r
   r   re   r   r2  r   r   rD   rf   rF   ru   r   r   r   r   r   r2  9  s&    	
#
r2  c                       sr   e Zd ZdZerejZ									d fdd	Z									d fdd	Z	dd Z
ed	d
 Z  ZS )FileDescriptora  Descriptor 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
    edition (Edition): Enum value indicating edition of the file
    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:`Descriptor`.
    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    |rt j|S tt| | S r   )r   r{   AddSerializedFiler   r:  r   )r   r6   packagerA   rB   rr   dependenciespublic_dependenciesr   rG   rR   r   r   r   r   r     s   zFileDescriptor.__new__c                    s   |t urtd tt| | ||d |	r|	dkr|	| _n|dkr%d| _nd| _|
du r6dd	lm} | }
|
| _	i | _
|| _|| _|| _i | _i | _i | _|pQg | _|pVg | _dS )
zConstructor.r:  FileOptionsEDITION_UNKNOWNproto3EDITION_PROTO3EDITION_PROTO2Nr   )descriptor_pool)r   r0   r   r:  rD   r\   rO   rD  DefaultrR   message_types_by_namer6   r<  rr   r   r   services_by_namer=  r>  )r!   r6   r<  rA   rB   rr   r=  r>  r   rG   rR   r   rD  r   r   r   rD     s.   

zFileDescriptor.__init__c                 C   s   | | j dS )z~Copies this to a descriptor_pb2.FileDescriptorProto.

    Args:
      proto: An empty descriptor_pb2.FileDescriptorProto.
    N)rq   rr   rs   r   r   r   ru     s   zFileDescriptor.CopyToProtoc                 C   rE   r   r   r$   r   r   r   rF     s   zFileDescriptor._parent)	NNNNNNNNN)r   r	   r
   r   re   r   r:  r   r   rD   ru   rf   rF   r   r   r   r   r   r:    s6    ,r:  c                 C   s   |  | | S )zParses serialized options.

  This helper function is used to parse serialized options in generated
  proto2 files. It must not be used outside proto2.
  )rq   )messagestringr   r   r   r_   	  s   
r_   c                 C   sn   d}g }| D ]}|dkr|rd}q|r| |  d}q||7 }q|r2|d  r2|d  |d< d|S )z+Converts name to camel-case and returns it.F_Tr    )appendupperisupperlowerjoinr6   capitalize_nextresultcr   r   r   r     s   

r   c                 C   s   |  dr| jS dS )zCReturns the value of the field `options`, or None if it is not set.rA   N)r`   rA   )descriptor_protor   r   r   _OptionsOrNone(  s   
rV  c                 C   sJ   d}g }| D ]}|dkrd}q|r| |  d}q||7 }qd|S )z*Converts name to Json name and returns it.FrJ  TrK  )rL  rM  rP  rQ  r   r   r   r   0  s   

r   rK  c                 C   s  ddl m} ttdd}|r!tj|	dd|d }n|d }t
 dkrV|rV| }	|	j |  |r>||	_||	_tj|	 tj|	j}
trV|
j| j S |d	u rhtd	||||d	d
g g td
}| jg}|rt|d| i }| jD ]"}d||jg }t|j|d	dd t|jD |td}|||< qyi }| jD ]}d||jg }t |d|d|||d}|||< qg }| j!D ]l}d||jg }d	}d	}|j"r|j"}nd	}|#dr|j$}d|||%dd d	 g }||v r|| }n	||v r|| }t&|j||j'd |j'|j(t&)|j(|j*d	||d	dd	t+|d||td}|,| qd|}t-| j|d	d	|t.|/ t.|/ g t+| |tdS )ap  Make 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.
    edition: The edition that should be used if syntax is "edition".
    file_desc: A FileDescriptor to place this descriptor into.

  Returns:
    A Descriptor for protobuf messages.
  r   rM   r   ascii./z.protor   NrK  )
rR   r6   r<  r   rG   rA   rr   r=  r>  r   c                 S   s$   g | ]\}}t |j||jtd qS ))r   )r   r6   r   r   )r   iienum_valr   r   r   
<listcomp>  s    z"MakeDescriptor.<locals>.<listcomp>)r;   r   F)r<  build_file_if_cppr   rG   	file_desc	type_namer,   )rA   r   r   r;   r   )rA   r;   r   )0rO   rN   binasciihexlifyosurandomdecodepathrP  replacer   r   FileDescriptorProtor   addrT   r<  r6   r   r{   AddFindFileByNamere   rF  r:  r   insertr   r  	enumerater   r   MakeDescriptorr   r   r`   r_  rfindr   r   r   r   r   rV  rL  rw   listr   )
desc_protor<  r]  r   rG   r^  rN   
proto_name	file_namefile_descriptor_protorS  full_message_namer   
enum_protork   	enum_descr   nested_protonested_descr~   field_protor   r_  full_type_namer   	desc_namer   r   r   rm  A  s   
	









rm  )rK  TNNN)/r   
__author__rg   r`  rb  r   r2   google.protobuf.internalr   re   r   	_c_moduler   google.protobuf.pyext	Exceptionr   r   r   r   ABCMetar   r   r   r    r0   r   r   r   r   r  r1   r   r9   rj   rw   r   r  r   r%  r(  r2  r:  r_   r   rV  r   rm  r   r   r   r   <module>   sj   
 7 <  >a40S`p
