
    q	h.                        S r SrSSKrSSKrSSKrSSKJr  SSKJr  SSKJr  SSK	J
r
  SSK	Jr  \R                  rS	 rS
 rS r\R                   " 5       r " S S\5      rS r\(       a  \R*                  R,                  rO\" 5       rS rg)aK  Provides DescriptorPool to use as a container for proto2 descriptors.

The DescriptorPool is used in conjection with a DescriptorDatabase to maintain
a collection of protocol buffer descriptors for use when dynamically creating
message types at runtime.

For most applications protocol buffers should be used via modules generated by
the protocol buffer compiler tool. This should only be used when the type of
protocol buffers used in an application or library cannot be predetermined.

Below is a straightforward example on how to use this class::

  pool = DescriptorPool()
  file_descriptor_protos = [ ... ]
  for file_descriptor_proto in file_descriptor_protos:
    pool.Add(file_descriptor_proto)
  my_message_descriptor = pool.FindMessageTypeByName('some.package.MessageType')

The message descriptor can be used in conjunction with the message_factory
module in order to create a protocol buffer class that can be encoded and
decoded.

If you want to get a Python class for the specified proto, use the
helper functions inside google.protobuf.message_factory
directly instead of this class.
z"matthewtoia@google.com (Matt Toia)    N)
descriptor)descriptor_database)text_encoding)python_edition_defaults)python_messagec                 $    U R                  S5      $ )a;  Remove leading period from fully-qualified type name.

Due to b/13860351 in descriptor_database.py, types in the root namespace are
generated with a leading period. This function removes that prefix.

Args:
  name (str): The fully-qualified symbol name.

Returns:
  str: The normalized fully-qualified symbol name.
.)lstripnames    Q/var/www/html/env/lib/python3.13/site-packages/google/protobuf/descriptor_pool.py_NormalizeFullyQualifiedNamer   2   s     
S	    c                 H    U R                  S5      (       a  U R                  $ g)zCReturns the value of the field `options`, or None if it is not set.optionsN)HasFieldr   )descriptor_protos    r   _OptionsOrNoner   A   s"    y))###r   c                 b   U R                   =(       a    U R                  R                  =(       a    U R                  R                  5       R                  =(       aU    U R
                  [        R                  R                  :H  =(       a'    U R                  [        R                  R                  :H  $ N)is_extensioncontaining_typehas_options
GetOptionsmessage_set_wire_formattyper   FieldDescriptorTYPE_MESSAGElabelLABEL_OPTIONAL)fields    r   _IsMessageSetExtensionr"   I   s    


 C



+
+C



*
*
,
D
DC **
22??
?C ++33BB
B	Dr   c                   :   \ rS rSrSr\(       a  S-S jr S.S jrS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S  r"  S/S! jr#  S0S" jr$ S1S# jr%S$ r&S% r'S& r(S' r)S( r*S) r+S-S* jr,S+ r-S,r.g)2DescriptorPoolS   zGA collection of protobufs dynamically constructed by descriptor protos.Nc                 @    [         R                  R                  U5      $ r   )r   _messager$   )clsdescriptor_dbs     r   __new__DescriptorPool.__new__X   s    ..}==r   c                 j   [         R                  " 5       U l        Xl        0 U l        0 U l        0 U l        0 U l        0 U l        0 U l	        [        R                  " [        5      U l        [        R                  " [        5      U l        [        R                   U l        SU l        [        5       U l        g)a$  Initializes a Pool of proto buffs.

The descriptor_db argument to the constructor is provided to allow
specialized file descriptor proto lookup code to be triggered on demand. An
example would be an implementation which will read and compile a file
specified in a call to FindFileByName() and not require the call to Add()
at all. Results from this database will be cached internally here as well.

Args:
  descriptor_db: A secondary source of file descriptors.
  use_deprecated_legacy_json_field_conflicts: Unused, for compatibility with
    C++.
N)r   DescriptorDatabase_internal_db_descriptor_db_descriptors_enum_descriptors_service_descriptors_file_descriptors_toplevel_extensions_top_enum_valuescollectionsdefaultdictdict_extensions_by_name_extensions_by_numberr   *_PROTOBUF_INTERNAL_PYTHON_EDITION_DEFAULTS_serialized_edition_defaults_edition_defaults_feature_cache)selfr)   *use_deprecated_legacy_json_field_conflictss      r   __init__DescriptorPool.__init__\   s    " ,>>@D'DD "DD "DD  +66t<D!,!8!8!>DJJ 	% "D&Dr   c                    U R                   [        R                  4U R                  [        R                  4U R
                  [        R                  4U R                  [        R                  4U R                  [        R                  44 H  u  pEX$;   d  M  XB   n[        U[        R                  5      (       a!  UR                  R                  R                  nOUR                  R                  n[        X5      (       a  Xs:w  aC  SU-   S-   U-   S-   U-   S-   n[        U[        R                  5      (       a  US-  n[        U5      e  g   g)zCheck if the descriptor name conflicts with another of the same name.

Args:
  desc: Descriptor of a message, enum, service, extension or enum value.
  desc_name (str): the full name of desc.
  file_name (str): The file name of descriptor.
zConflict register for file "z": z is already defined in file "zo". Please fix the conflict by adding package name on the proto file, or use different name for the duplication.zQ
Note: enum values appear as siblings of the enum type instead of children of it.N)r0   r   
Descriptorr1   EnumDescriptorr2   ServiceDescriptorr4   r   r5   EnumValueDescriptor
isinstancer   filer   	TypeError)	r?   desc	desc_name	file_nameregisterdescriptor_typeold_descold_file	error_msgs	            r   _CheckConflictRegister%DescriptorPool._CheckConflictRegister   s;    
		J112			!:!:;		"	"J$@$@A		"	"J$>$>?			
 > >?&A! 
	&h
 > >??]]'',,(]]''($00!5	A()67   #33) j<<== , -I )$
$9&Ar   c                 :    U R                   R                  U5        g)zAdds the FileDescriptorProto and its types to this pool.

Args:
  file_desc_proto (FileDescriptorProto): The file descriptor to add.
N)r.   Add)r?   file_desc_protos     r   rV   DescriptorPool.Add   s     	/*r   c                 v    SSK Jn  UR                  R                  U5      nU R	                  U5      nXl        U$ )zAdds the FileDescriptorProto and its types to this pool.

Args:
  serialized_file_desc_proto (bytes): A bytes string, serialization of the
    :class:`FileDescriptorProto` to add.

Returns:
  FileDescriptor: Descriptor for the added file.
r   descriptor_pb2)google.protobufr[   FileDescriptorProto
FromString!_ConvertFileProtoToFileDescriptorserialized_pb)r?   serialized_file_desc_protor[   rW   	file_descs        r   AddSerializedFile DescriptorPool.AddSerializedFile   s<     /$88CC"$O66GI8r   c                    [        U[        R                  5      (       d  [        S5      eU R	                  XR
                  UR                  R                  5        XR                  UR
                  '   U R                  UR                  5        g)zAdds a Descriptor to the pool, non-recursively.

If the Descriptor contains nested messages or enums, the caller must
explicitly register them. This method also registers the FileDescriptor
associated with the message.

Args:
  desc: A Descriptor.
z+Expected instance of descriptor.Descriptor.N)
rH   r   rD   rJ   rS   	full_namerI   r   r0   _AddFileDescriptor)r?   rK   s     r   _AddDescriptorDescriptorPool._AddDescriptor   sc     dJ1122CDDnndiinnE(,dnn%DII&r   c                 4   [        U[        R                  5      (       d  [        S5      eUR                  R
                  nU R                  XR                  U5        XR                  UR                  '   UR                  R                  (       aE  UR                  R                  S5      UR                  R                  R                  S5      -
  S:H  nOUR                  R                  S5      S:H  nU(       a  UR                  R
                  nUR                  R                  nUR                   HH  n[        SR                  XER
                  45      5      nU R                  XVU5        XPR                  U'   MJ     U R                  UR                  5        g)zAdds an EnumDescriptor to the pool.

This method also registers the FileDescriptor associated with the enum.

Args:
  enum_desc: An EnumDescriptor.
z/Expected instance of descriptor.EnumDescriptor.r	      r   N)rH   r   rE   rJ   rI   r   rS   rf   r1   packagecountvaluesr   joinr5   rg   )r?   	enum_descrM   	top_levelrl   
enum_valuerf   s          r   _AddEnumDescriptor!DescriptorPool._AddEnumDescriptor   sC    i!:!:;;GHH##I	+>+>	J2;9../
 ~~&&,,S1^^++11#67:;<i %%++C0A5i..%%i&&g!((*0HHg/02	##J9E+5i(	 )
 	INN+r   c                     [        U[        R                  5      (       d  [        S5      eU R	                  XR
                  UR                  R                  5        XR                  UR
                  '   g)zRAdds a ServiceDescriptor to the pool.

Args:
  service_desc: A ServiceDescriptor.
z2Expected instance of descriptor.ServiceDescriptor.N)	rH   r   rF   rJ   rS   rf   rI   r   r2   )r?   service_descs     r   _AddServiceDescriptor$DescriptorPool._AddServiceDescriptor   s\     lJ$@$@AAJKK.D.D , 1 1 6 688Dl445r   c                    [        U[        R                  5      (       a  UR                  (       d  [	        S5      eUR
                  cH  U R                  XR                  UR                  R                  5        XR                  UR                  '    U R                  UR                     UR                     nXLaD  [        SUR                  UR                  UR                  R                  UR                  4-  5      e UU R                  UR                     UR                  '   UU R                   UR                     UR                  '   [#        U5      (       a0  UU R                   UR                     UR$                  R                  '   ['        UR                  S5      (       a,  [(        R*                  " UR                  R,                  U5        gg! [         a     Nf = f)a  Adds a FieldDescriptor describing an extension to the pool.

Args:
  extension: A FieldDescriptor.

Raises:
  AssertionError: when another extension with the same number extends the
    same message.
  TypeError: when the specified extension is not a
    descriptor.FieldDescriptor.
z!Expected an extension descriptor.NzSExtensions "%s" and "%s" both try to extend message type "%s" with field number %d._concrete_class)rH   r   r   r   rJ   extension_scoperS   rf   rI   r   r4   r:   r   numberAssertionErrorKeyErrorr9   r"   message_typehasattrr   _AttachFieldHelpersrz   )r?   	extensionexisting_descs      r   _AddExtensionDescriptor&DescriptorPool._AddExtensionDescriptor  s    y*"<"<==""9::  (
!!
(()..*=*=?7@	 3 34E00

#
#%%.%5%57m
 
	'$  -"9"9&&00)2B2BDDE 	E 
( & 	y889  ) 	Y667 i((.7 y889

 
 
*
*, y((*;<<((

#
#
3
3Y@ =)  
s   &G 
G"!G"c                 &    U R                  U5        g)Adds a FileDescriptor to the pool, non-recursively.

If the FileDescriptor contains messages or enums, the caller must explicitly
register them.

Args:
  file_desc: A FileDescriptor.
N)rg   r?   rb   s     r   _InternalAddFileDescriptor)DescriptorPool._InternalAddFileDescriptor9  s     	I&r   c                     [        U[        R                  5      (       d  [        S5      eXR                  UR
                  '   g)r   z/Expected instance of descriptor.FileDescriptor.N)rH   r   FileDescriptorrJ   r3   r   r   s     r   rg   !DescriptorPool._AddFileDescriptorE  s5     i!:!:;;GHH-69>>*r   c                 R    U R                   U   $ ! [         a     Of = f U R                  R                  U5      nOE! [         a8  nU R                  (       a   U R                  R                  U5      n SnAO
UeSnAff = fU(       d  [        SU-  5      eU R                  U5      $ )zGets a FileDescriptor by file name.

Args:
  file_name (str): The path to the file to get a descriptor for.

Returns:
  FileDescriptor: The descriptor for the named file.

Raises:
  KeyError: if the file cannot be found in the pool.
NzCannot find a file named %s)r3   r~   r.   FindFileByNamer/   r_   )r?   rM   
file_protoerrors       r   r   DescriptorPool.FindFileByNameS  s    ##I.. 
$$33I>j 			((77	B
	
 2Y>??11*==s'    
> 
B ,A;9A;;B c                     [        U5      n U R                  U5      $ ! [         a     Of = f U R                  U5        U R                  U5      $ ! [         a    [        SU-  5      ef = f)a  Gets the FileDescriptor for the file containing the specified symbol.

Args:
  symbol (str): The name of the symbol to search for.

Returns:
  FileDescriptor: Descriptor for the file that contains the specified
  symbol.

Raises:
  KeyError: if the file cannot be found in the pool.
 Cannot find a file containing %s)r   !_InternalFindFileContainingSymbolr~   _FindFileContainingSymbolInDb)r?   symbols     r   FindFileContainingSymbol'DescriptorPool.FindFileContainingSymbolp  s}     *&1F33F;; 
B
((033F;; B7&@AABs    
++!A A*c                     U R                   U   R                  $ ! [         a     Of = f U R                  U   R                  $ ! [         a     Of = f U R                  U   R                  $ ! [         a     Of = f U R
                  U   R                  R                  $ ! [         a     Of = f U R                  U   R                  $ ! [         a     Of = fUR                  S5      u  p#n U R                  U5      nXER                  ;   d   XER                  ;   d  XER                  ;   d   eUR                  $ ! [        [        4 a    [        SU-  5      ef = f)a  Gets the already built FileDescriptor containing the specified symbol.

Args:
  symbol (str): The name of the symbol to search for.

Returns:
  FileDescriptor: Descriptor for the file that contains the specified
  symbol.

Raises:
  KeyError: if the file cannot be found in the pool.
r	   r   )r0   rI   r~   r1   r2   r5   r   r4   
rpartitionFindMessageTypeByNameextensions_by_namefields_by_nameenum_values_by_namer}   )r?   r   top_name_sub_namemessages         r   r   0DescriptorPool._InternalFindFileContainingSymbol  s|   v&+++ 
##F+000 
&&v.333 
""6*//444 
&&v.333 
 #--c2HB**84g4440005557 6 \\n% B7&@AABs`    
((A 
AAA/ /
A<;A< "B# #
B0/B04C 
CC2AD> >Ec                 v    [        U5      nXR                  ;  a  U R                  U5        U R                  U   $ )zLoads the named descriptor from the pool.

Args:
  full_name (str): The full name of the descriptor to load.

Returns:
  Descriptor: The descriptor for the named type.

Raises:
  KeyError: if the message cannot be found in the pool.
)r   r0   r   r?   rf   s     r   r   $DescriptorPool.FindMessageTypeByName  s9     -Y7I)))
((3Y''r   c                 v    [        U5      nXR                  ;  a  U R                  U5        U R                  U   $ )zLoads the named enum descriptor from the pool.

Args:
  full_name (str): The full name of the enum descriptor to load.

Returns:
  EnumDescriptor: The enum descriptor for the named type.

Raises:
  KeyError: if the enum cannot be found in the pool.
)r   r1   r   r   s     r   FindEnumTypeByName!DescriptorPool.FindEnumTypeByName  s9     -Y7I...
((3!!),,r   c                     [        U5      nUR                  S5      u  p#nU R                  U5      nUR                  U   $ )zLoads the named field descriptor from the pool.

Args:
  full_name (str): The full name of the field descriptor to load.

Returns:
  FieldDescriptor: The field descriptor for the named field.

Raises:
  KeyError: if the field cannot be found in the pool.
r	   )r   r   r   r   )r?   rf   message_namer   
field_namemessage_descriptors         r   FindFieldByNameDescriptorPool.FindFieldByName  E     -Y7I"+"6"6s";LZ33LA,,Z88r   c                     [        U5      nUR                  S5      u  p#nU R                  U5      nUR                  U   $ )zLoads the named oneof descriptor from the pool.

Args:
  full_name (str): The full name of the oneof descriptor to load.

Returns:
  OneofDescriptor: The oneof descriptor for the named oneof.

Raises:
  KeyError: if the oneof cannot be found in the pool.
r	   )r   r   r   oneofs_by_name)r?   rf   r   r   
oneof_namer   s         r   FindOneofByNameDescriptorPool.FindOneofByName  r   r   c                    [        U5      n U R                  U   $ ! [         a     Of = fUR                  S5      u  p#n U R	                  U5      nO!! [         a    U R                  U5      n Of = fUR                  U   $ )a  Loads the named extension descriptor from the pool.

Args:
  full_name (str): The full name of the extension descriptor to load.

Returns:
  FieldDescriptor: The field descriptor for the named extension.

Raises:
  KeyError: if the extension cannot be found in the pool.
r	   )r   r4   r~   r   r   r   r   )r?   rf   r   r   extension_namescopes         r   FindExtensionByName"DescriptorPool.FindExtensionByName  s     -Y7I
 &&y11 
&/&:&:3&?#L^<((6e <00;e< ##N33s    
))A A10A1c                      U R                   U   U   $ ! [         a&    U R                  X5        U R                   U   U   s $ f = f)a  Gets the extension of the specified message with the specified number.

Extensions have to be registered to this pool by calling :func:`Add` or
:func:`AddExtensionDescriptor`.

Args:
  message_descriptor (Descriptor): descriptor of the extended message.
  number (int): Number of the extension field.

Returns:
  FieldDescriptor: The descriptor for the extension.

Raises:
  KeyError: when no extension with the given number is known for the
    specified message.
)r:   r~   _TryLoadExtensionFromDB)r?   r   r|   s      r   FindExtensionByNumber$DescriptorPool.FindExtensionByNumber   sV    "D''(:;FCC D
""#5>''(:;FCCDs    -AAc                 P   U R                   (       ap  [        U R                   S5      (       aU  UR                  nU R                   R                  U5      nU H(  nX@R                  U   ;   a  M  U R                  X5        M*     [        U R                  U   R                  5       5      $ )a?  Gets all the known extensions of a given message.

Extensions have to be registered to this pool by build related
:func:`Add` or :func:`AddExtensionDescriptor`.

Args:
  message_descriptor (Descriptor): Descriptor of the extended message.

Returns:
  list[FieldDescriptor]: Field descriptors describing the extensions.
FindAllExtensionNumbers)r/   r   rf   r   r:   r   listrn   )r?   r   rf   all_numbersr|   s        r   FindAllExtensions DescriptorPool.FindAllExtensions7  s     w6 8  8$..i''??	Jk&//0BCC
$$%7@  
 **+=>EEGHHr   c                 @   U R                   (       d  g[        U R                   S5      (       d  gUR                  nU R                   R                  X25      nUc  g U R	                  U5        g!   SUR
                  U4-  n[        R                  " U[        5         g= f)zTry to Load extensions from descriptor db.

Args:
  message_descriptor: descriptor of the extended message.
  number: the extension number that needs to be loaded.
NFindFileContainingExtensionz5Unable to load proto file %s for extension number %d.)	r/   r   rf   r   r_   r   warningswarnRuntimeWarning)r?   r   r|   rf   r   warn_msgs         r   r   &DescriptorPool._TryLoadExtensionFromDBO  s     :< <",,I$$@@J .
,,Z8.I??F+,hmmHn-s   A- -.Bc                 v    [        U5      nXR                  ;  a  U R                  U5        U R                  U   $ )a  Loads the named service descriptor from the pool.

Args:
  full_name (str): The full name of the service descriptor to load.

Returns:
  ServiceDescriptor: The service descriptor for the named service.

Raises:
  KeyError: if the service cannot be found in the pool.
)r   r2   r   r   s     r   FindServiceByName DescriptorPool.FindServiceByNamek  s9     -Y7I111
((3$$Y//r   c                     [        U5      nUR                  S5      u  p#nU R                  U5      nUR                  U   $ )a  Loads the named service method descriptor from the pool.

Args:
  full_name (str): The full name of the method descriptor to load.

Returns:
  MethodDescriptor: The method descriptor for the service method.

Raises:
  KeyError: if the method cannot be found in the pool.
r	   )r   r   r   methods_by_name)r?   rf   service_namer   method_nameservice_descriptors         r   FindMethodByNameDescriptorPool.FindMethodByName|  sE     -Y7I#,#7#7#< L[//=--k::r   c           	          U R                   b  [        S5      eSSKJn  [	        XR
                  5      (       d  [        S5      eUR                  UR                  :  aY  [        SUR                  R                  UR                  5      < SUR                  R                  UR                  5      < 35      eUR                  R                  nUR                   H  nUR                  UR                  R                  :X  a  [        S5      eX4R                  :  aO  [        S	UR                  R                  U5      < S
UR                  R                  UR                  5      < 35      eUR                  nM     Xl         g)zSets the default feature mappings used during the build.

Args:
  defaults: a FeatureSetDefaults message containing the new mappings.
NzIFeature set defaults can't be changed once the pool has started building!r   rZ   z.SetFeatureSetDefaults called with invalid typezInvalid edition range z to z)Invalid edition EDITION_UNKNOWN specifiedz3Feature set defaults are not strictly increasing.  z is greater than or equal to )r=   
ValueErrorr\   r[   rH   FeatureSetDefaultsrJ   minimum_editionmaximum_editionEditionNameEDITION_UNKNOWNdefaultsedition)r?   r   r[   prev_editionds        r   SetFeatureSetDefaults$DescriptorPool.SetFeatureSetDefaults  sF    )  /h A ABBFGG (":":: $$))(*B*BC$$))(*B*BC  "))99L	
n,,<<	<DEE		" &&++L9&&++AII6	
 	
 YYl  &r   c                    SSK Jn  [           U R                  (       d:  UR	                  5       U l        U R                  R                  U R                  5        SSS5        XR                  R                  :  aZ  [        SUR                  R                  U5      < SUR                  R                  U R                  R                  5      < S35      eXR                  R                  :  aZ  [        SUR                  R                  U5      < SUR                  R                  U R                  R                  5      < S35      eSnU R                  R                   H  nUR                  U:  a    OUnM     Uc'  [        SUR                  R                  U5      -  5      eUR                  5       nUR                  UR                   5        UR#                  UR$                  5        U$ ! , (       d  f       GN= f)	zCreates a FeatureSet message with defaults for a specific edition.

Args:
  edition: the edition to generate defaults for.

Returns:
  A FeatureSet message with defaults for a specific edition.
r   rZ   NzEdition z/ is earlier than the minimum supported edition !z- is later than the maximum supported edition z&No valid default found for edition %s!)r\   r[   _edition_defaults_lockr=   r   ParseFromStringr<   r   rJ   r   r   r   r   r   
FeatureSetCopyFromfixed_features	MergeFromoverridable_features)r?   r   r[   foundr   r   s         r   _CreateDefaultFeatures%DescriptorPool._CreateDefaultFeatures  s    /	##!/!B!B!D..--	
 
  ''777 $$))'2$$))((88  ''777 $$))'2$$))((88  E##,,	
W	e - }
2""''01 
 ((*He**+u112OS 
 	s   AG,,
G;c                     UR                  5       n[           U R                  R                  U5      nUc  XR                  U'   UnS S S 5        U$ ! , (       d  f       W$ = fr   )SerializeToStringr   r>   get)r?   features
serializedcacheds       r   _InternFeaturesDescriptorPool._InternFeatures  s]    ++-J	""&&z2f	*2J'	 
 
 M 
 	
 Ms   /A
Ac                     U R                   R                  U5      nU(       d  [        SU-  5      eU R	                  U5      $ ! [         a8  nU R                  (       a   U R                  R                  U5      n SnANaUeSnAff = f)a  Finds the file in descriptor DB containing the specified symbol.

Args:
  symbol (str): The name of the symbol to search for.

Returns:
  FileDescriptor: The file that contains the specified symbol.

Raises:
  KeyError: if the file cannot be found in the descriptor database.
Nr   )r.   r   r~   r/   r_   )r?   r   r   r   s       r   r   ,DescriptorPool._FindFileContainingSymbolInDb  sz    $$==fEj 7&@AA11*==  			((AA&I
	s   A 
B,B >B  Bc                   ^ ^ UR                   T R                  ;  Ga  [        T R                  UR                  5      5      nUR                   Vs/ s H  nT R                  U5      PM     nnUR                   Vs/ s H  oTU   PM	     nnSSKJn  [        R                  " T UR                   UR                  UR                  UR                  R                  UR                  5      [!        U5      UR#                  5       UU[        R$                  S9
n0 n	U Hk  n
U	R'                  T R)                  U
R*                  R-                  5       5      5        U	R'                  S U
R.                  R-                  5        5       5        Mm     UR0                   HC  nT R3                  XR                  XUR                  5      nUUR*                  UR                   '   ME     UR4                   H9  nT R7                  XR                  USU	S5      UR.                  UR                   '   M;     [9        UR:                  5       H  u  pT R=                  XR                  XSS9nT R?                  UR                  UR@                  U	5      Ul!        T RE                  UUUR                  U	5        UURF                  UR                   '   M     UR0                   H   nT RI                  UR                  UU	5        M"     UR                  (       a  [K        UR                  5      nOSnUR0                   H9  nT R?                  UUR                   U	5      nUUR*                  UR                   '   M;     [9        URL                  5       H;  u  nnT RO                  UXUR                  U5      URP                  UR                   '   M=     UT R                  UR                   '   UU 4S	 jmT R                  UR                      nURF                  R-                  5        H  nT RS                  U5        M     UR*                  R-                  5        H  nT" U5        M     U$ s  snf s  snf )
a(  Creates a FileDescriptor from a proto or returns a cached copy.

This method also has the side effect of loading all the symbols found in
the file into the appropriate dictionaries in the pool.

Args:
  file_proto: The proto to convert.

Returns:
  A FileDescriptor matching the passed in proto.
r   rZ   )
poolr   rl   syntaxr   r   r`   dependenciespublic_dependencies
create_keyc              3   P   #    U  H  n[        UR                  5      U4v   M     g 7fr   )_PrefixWithDotrf   ).0enums     r   	<genexpr>CDescriptorPool._ConvertFileProtoToFileDescriptor.<locals>.<genexpr>:  s&      I!G %T^^4d;!Gs   $&NTr    c                    > U R                    H  nT" U5        M     U R                   H  nTR                  U5        M     g r   )nested_types
extensionsr   )r   nestedr   AddExtensionForNestedr?   s      r   r  ODescriptorPool._ConvertFileProtoToFileDescriptor.<locals>.AddExtensionForNestedi  s9     --&f% .#..)$$Y/ /r   )*r   r3   r   _GetDeps
dependencyr   public_dependencyr\   r[   r   r   rl   r   r   r   r   r   r   _internal_create_keyupdate_ExtractSymbolsmessage_types_by_namern   enum_types_by_namer   _ConvertMessageDescriptor	enum_type_ConvertEnumDescriptor	enumerater   _MakeFieldDescriptor_GetTypeFromScopeextendeer   _SetFieldTyper   _SetAllFieldTypesr  service_MakeServiceDescriptorservices_by_namer   )r?   r   
built_depsndirect_depsipublic_depsr[   file_descriptorr   r  r   message_descr  indexextension_protoextension_desc
desc_protodesc_proto_prefixrK   service_protorb   r   r  s   `                      @r   r_   0DescriptorPool._ConvertFileProtoToFileDescriptor  s    d444j&;&;<=j5?5J5JK5JT((+5JkK-7-I-IJ-I^-IkJ 1"11$$"" ((--j.@.@A ,"446")44o e #*T)),,3357 	8 I!+!>!>!E!E!GI 	I # %11,55,,o  	--l.?.?@	 2 "++)''	3E3E(7udL 	**9>>: ,
 %.j.B.B$C
 %22// 3  *.)?)?##_%=%=u*F&?N*22E	;  	**>+>+>? %D #//*z11:uE 0 
		*:+=+=>"//*%%z7AE--joo> 0
 #,J,>,>"?
%''u(2(:(:OM 	((););< #@
 1@dZ__-0 &&z7I1188:	
""9- ;!77>>@L) A o LJs   Q;Qc                    U(       a  SR                  X!R                  45      nOUR                  nUc  SnOUR                  nUc  0 nUR                   Vs/ s H  nU R                  XX4U5      PM     snnUR                   V	s/ s H  n	U R                  XUSUS5      PM     n
n	[        UR                  5       VVs/ s H  u  pU R                  XX5      PM     nnn[        UR                  5       VVs/ s H  u  pU R                  XXSS9PM     nnn[        UR                  5       VVs/ s H\  u  nn[        R                  " UR                  SR                  UUR                  45      US/ [        U5      [        R                  S9PM^     nnnUR                   Vs/ s H  nUR                   UR"                  4PM     nnU(       a  SnOSn[        R$                  " S0 SUR                  _SU_S	U_S
S_SU_SU_SU_SU
_SU_S[        U5      _SU_SU_SU_SS_SS_SUR&                  R(                  _S[        R                  _6nUR*                   H
  nUUl        M     UR.                   H
  n	UU	l        M     [        UR                  5       HX  u  nnUR1                  S5      (       d  M  UR2                  nUU   R4                  R7                  UU   5        UU   UU   l        MZ     UU[;        U5      '   U R=                  UUR>                  UR@                  R                  5        UU RB                  U'   U$ s  snf s  sn	f s  snnf s  snnf s  snnf s  snf )a  Adds the proto to the pool in the specified package.

Args:
  desc_proto: The descriptor_pb2.DescriptorProto protobuf message.
  package: The package the proto should be located in.
  file_desc: The file containing this message.
  scope: Dict mapping short and full symbols to message and enum types.
  syntax: string indicating syntax of the file ("proto2" or "proto3")

Returns:
  The added descriptor.
r	   NFTr  )r   r   rf   filenamer   fieldsoneofsr
  
enum_typesr  r   is_extendableextension_rangesrI   serialized_startserialized_endis_map_entryr   oneof_index )"ro   r   nested_typer  r  r  r  r!   r  r   
oneof_declr   OneofDescriptorr   r  extension_rangestartendrD   r   	map_entryr
  r   r5  r   r;  r3  appendcontaining_oneofr  rS   rf   rI   r0   )r?   r-  rl   rb   r   r   rL   rM   r  r  enumsr*  r!   r3  r   r  rK   r4  rr7  r6  field_index
field_descr;  s                           r   r  (DescriptorPool._ConvertMessageDescriptorw  s    ((G__56i//ii..i}e
 !,,. -F 	&&y	9,.F ((* )D 	##DY$)5	2( 
 *
 #,J,<,<"=?"=,% ''%K"=  ?
 !***>*> ?A !@E 	!!)/3 	" 	5 ?  A %Z%:%:; <KE4 	""IIHHi+,4 !66	8 <   3=2L2LM2LQ!%%(2LMmm   __  	
      z* $ *      ''11!$ 22%D( ###f $!d  #,Z-=-=#>Z			]	+	+ ,,{""))&*=>/5k/B{,	 $? (,E.
#$dnndiinnE#'Di KC.*?A Ns%   MM=M6M.A#M""Mc                    U(       a  SR                  X!R                  45      nOUR                  nUc  SnOUR                  n[        UR                  5       V	V
s/ s H  u  pU R	                  X5      PM     nn	n
[
        R                  " UR                  UUUUU[        U5      [
        R                  S9nXSU-  '   U R                  XR                  UR                  R                  5        XR                  U'   U(       aN  U HH  n
[        SR                  X*R                  45      5      nU R                  XU5        XR                  U'   MJ     U$ s  sn
n	f )a  Make a protobuf EnumDescriptor given an EnumDescriptorProto protobuf.

Args:
  enum_proto: The descriptor_pb2.EnumDescriptorProto protobuf message.
  package: Optional package name for the new message EnumDescriptor.
  file_desc: The file containing the enum descriptor.
  containing_type: The type containing this enum.
  scope: Scope containing available types.
  top_level: If True, the enum is a top level symbol. If False, the enum
      is defined inside a message.

Returns:
  The added descriptor
r	   N)r   rf   r2  rI   rn   r   r   r   .%s)ro   r   r  value_MakeEnumValueDescriptorr   rE   r   r  rS   rf   rI   r1   r   r5   )r?   
enum_protorl   rb   r   r   rq   	enum_namerM   r*  rM  rn   rK   rf   s                 r   r  %DescriptorPool._ConvertEnumDescriptor  s9   " ((G__56i//ii..i #,J,<,<"=?"=,% ++E9"=  ?$$*///8.7*3,25D-;J-G0:0O0OQD  $%)
nndiinnE(,9% %0HHgzz*+-	##Ei@+0i(	  K/?s   Ec                    U(       a  SR                  X!R                  45      nOUR                  nUR                  (       a  UR                  nOSn[        R                  " S0 SUR                  _SU_SU_SUR
                  _SUR                  _SS_S	S_S
S_SS_SUR                  _SS_SS_SU_SS_S[        U5      _SU_SU_S[        R                  _6$ )ak  Creates a field descriptor from a FieldDescriptorProto.

For message and enum type fields, this method will do a look up
in the pool for the appropriate descriptor for that type. If it
is unavailable, it will fall back to the _source function to
create it. If this type is still unavailable, construction will
fail.

Args:
  field_proto: The proto describing the field.
  message_name: The name of the containing message.
  index: Index of the field
  file_desc: The file containing the field descriptor.
  is_extension: Indication that this field is for an extension.

Returns:
  An initialized FieldDescriptor object
r	   Nr   rf   r*  r|   r   cpp_typer   r  r   r   has_default_valueFdefault_valuer   r{   r   	json_namerI   r   r<  )
ro   r   rV  r   r   r|   r   r   r   r  )r?   field_protor   r*  rb   r   rf   rV  s           r   r  #DescriptorPool._MakeFieldDescriptor
  s(   * ((L*:*:;<i""i''ii%% 444 4 !!	4
 4 4 4 4 4 4  4 4 "4 4 {+4  !4" #4& 22'4 4r   c                 :   [        U5      nU R                  XR                  U5      nUS:X  a  [        UR                  5      nOSR                  XR                  /5      n[	        UR
                  UR                  5       H  u  pgU R                  XgXS5        M     [	        UR                  UR                  5       H8  u  pU R                  XXR                  U5      U	l        U R                  XXS5        M:     UR                   H  n
U R                  XZU5        M     g)zSets all the descriptor's fields's types.

This method also sets the containing types on any extensions.

Args:
  package: The current package of desc_proto.
  desc_proto: The message descriptor to update.
  scope: Enclosing scope of available types.
r	   N)r  r  r   ro   zipr!   r3  r  r   r  r  r   r=  r  )r?   rl   r-  r   	main_descnested_packagerW  rI  r+  r,  r=  s              r   r   DescriptorPool._SetAllFieldTypes>  s     W%G&&wGI#~%joo6nxx// :;n#&z'7'79I9I#J
.H $K 	J  )"6"67 	('+'='=
22E(;n$
.P 	8
 "--
^%@ .r   c                 
   UR                   (       a  U R                  X1R                   U5      nOSnUR                  S5      (       d^  [        U[        R
                  5      (       a   [        R                  R                  Ul        O[        R                  R                  Ul        [        R                  R                  UR                  5      Ul        UR                  [        R                  R                  :X  d(  UR                  [        R                  R                  :X  a  XRl        UR                  [        R                  R                  :X  a  XRl        UR                  [        R                  R                   :X  a  SUl        / Ul        GOUR                  S5      (       Ga  SUl        UR                  [        R                  R&                  :X  d(  UR                  [        R                  R(                  :X  a  [+        UR$                  5      Ul        GO(UR                  [        R                  R,                  :X  a  UR$                  Ul        GOUR                  [        R                  R.                  :X  a$  UR$                  R1                  5       S:H  Ul        GOUR                  [        R                  R                  :X  a4  UR                  R2                  UR$                     R4                  Ul        GOEUR                  [        R                  R6                  :X  a'  [8        R:                  " UR$                  5      Ul        GOUR                  [        R                  R                  :X  a	  SUl        GO[=        UR$                  5      Ul        GOSUl        UR                  [        R                  R&                  :X  d(  UR                  [        R                  R(                  :X  a	  SUl        GOIUR                  [        R                  R,                  :X  a	  SUl        GOUR                  [        R                  R.                  :X  a  SUl        OUR                  [        R                  R                  :X  a)  UR                  R>                  S	   R4                  Ul        OUR                  [        R                  R6                  :X  a  S
Ul        OgUR                  [        R                  R                  :X  a  SUl        O7UR                  [        R                  R                  :X  a  SUl        OS	Ul        UR                  Ul        g)a  Sets the field's type, cpp_type, message_type and enum_type.

Args:
  field_proto: Data about the field in proto format.
  field_desc: The descriptor to modify.
  package: The package the field's container is in.
  scope: Enclosing scope of available types.
Nr   FrU  Ttrueg        r  r   r   ) 	type_namer  r   rH   r   rD   r   r   r   	TYPE_ENUMProtoTypeToCppProtoTyperS  
TYPE_GROUPr   r  r   LABEL_REPEATEDrT  rU  TYPE_DOUBLE
TYPE_FLOATfloatTYPE_STRING	TYPE_BOOLlowervalues_by_namer|   
TYPE_BYTESr   	CUnescapeintrn   )r?   rW  rI  rl   r   rK   s         r   r  DescriptorPool._SetFieldType^  s    ##G-B-BEJdd''	D*//	0	0%55BB%55??$44LLJ 	J66CCCz99DDD $:55???!J66EEE%*j"!#j			o	.	.%)j"


j88DD
D


j88CC
C#()B)B#C
 z99EEE#.#<#<
 z99CCC#.#<#<#B#B#D#N
 z99CCC#-#7#7#F#F%%$''-v 	 z99DDD#0#:#:%%$'
 z99FFF#'
  $'{'@'@#A
 %*j"


j88DD
D


j88CC
C#&
 z99EEE#&
 z99CCC#(
 z99CCC#-#7#7#>#>q#A#H#H
 z99DDD#&
 z99FFF#'
 z99DDD#'
  $%
 !&&JOr   c           	          [         R                  " UR                  UUR                  [	        U5      S[         R
                  S9$ )zCreates a enum value descriptor object from a enum value proto.

Args:
  value_proto: The proto describing the enum value.
  index: The index of the enum value.

Returns:
  An initialized EnumValueDescriptor object.
N)r   r*  r|   r   r   r   )r   rG   r   r|   r   r  )r?   value_protor*  s      r   rN  'DescriptorPool._MakeEnumValueDescriptor  s@     ))!!{+224 4r   c                    U(       a  SR                  XAR                  45      nOUR                  n[        UR                  5       VVs/ s H  u  pxU R	                  XUX75      PM     n	nn[
        R                  " UR                  UUU	[        U5      U[
        R                  S9n
U R                  XR                  U
R                  R                  5        XR                  U'   U
$ s  snnf )a  Make a protobuf ServiceDescriptor given a ServiceDescriptorProto.

Args:
  service_proto: The descriptor_pb2.ServiceDescriptorProto protobuf message.
  service_index: The index of the service in the File.
  scope: Dict mapping short and full symbols to message and enum types.
  package: Optional package name for the new message EnumDescriptor.
  file_desc: The file containing the service descriptor.

Returns:
  The added descriptor.
r	   )r   rf   r*  methodsr   rI   r   )ro   r   r  method_MakeMethodDescriptorr   rF   r   r  rS   rf   rI   r2   )r?   r/  service_indexr   rl   rb   r   r*  method_protort  rK   s              r   r!  %DescriptorPool._MakeServiceDescriptor  s     XXw(:(:;<l"''l +4M4H4H*IK*I&5 )),g*/8*I  K ''}-224D 	nndiinnE.2l+KKs   	C&c                 N   SR                  X!R                  45      nU R                  X1R                  U5      nU R                  X1R                  U5      n[
        R                  " UR                  UUSUUUR                  UR                  [        U5      [
        R                  S9
$ )ai  Creates a method descriptor from a MethodDescriptorProto.

Args:
  method_proto: The proto describing the method.
  service_name: The name of the containing service.
  package: Optional package name to look up for types.
  scope: Scope containing available types.
  index: Index of the method in the service.

Returns:
  An initialized MethodDescriptor object.
r	   N)
r   rf   r*  containing_service
input_typeoutput_typeclient_streamingserver_streamingr   r   )ro   r   r  r|  r}  r   MethodDescriptorr~  r  r   r  )	r?   rx  r   rl   r   r*  rf   r|  r}  s	            r   rv  $DescriptorPool._MakeMethodDescriptor  s     ,(9(9:;I''((%1J(())52K&&%66%66|,224 4r   c              #      #    U Hn  n[        UR                  5      U4v   U R                  UR                  5       H  nUv   M	     UR                   H  n[        UR                  5      U4v   M     Mp     g7f)zPulls out all the symbols from descriptor protos.

Args:
  descriptors: The messages to extract descriptors from.
Yields:
  A two element tuple of the type name and descriptor object.
N)r  rf   r  r
  r5  )r?   descriptorsrK   r   r  s        r   r  DescriptorPool._ExtractSymbols  sg      DNN+T22(():):;& <//$dnn-t44 "	 s   A6A8c              #   (  #    U=(       d
    [        5       nU Hn  nX2;  d  M
  UR                  U5        U R                  U5      nUv   UR                   Vs/ s H  oUR                  PM     nnU R                  Xb5       Sh  vN   Mp     gs  snf  N7f)zRecursively finds dependencies for file protos.

Args:
  dependencies: The names of the files being depended on.
  visited: The names of files already found.

Yields:
  Each direct and indirect dependency.
N)setaddr   r   r   r  )r?   r   visitedr  dep_descr   public_filess          r   r  DescriptorPool._GetDeps  s}      G"
		"J&&z2(0(D(DE(D1(DE==777 #
 F7s"   B4BB+BBBc                     X#;  a[  [        U5      R                  S5      nU(       a:  SR                  XB/-   5      nXS;   a  Un X2   $ UR                  S5        U(       a  M:  X2   $ )a#  Finds a given type name in the current scope.

Args:
  package: The package the proto should be located in.
  type_name: The name of the type to be found in the scope.
  scope: Dict mapping short and full symbols to message and enum types.

Returns:
  The descriptor for the requested type.
r	   )r  splitro   pop)r?   rl   r`  r   
componentspossible_matchs         r   r   DescriptorPool._GetTypeFromScope&  sn     !'*005j*{":;"$)
  ..
 J r   )r/   r0   r=   r1   r9   r:   r>   r3   r.   r<   r2   r5   r4   r   )NF)NNNN)NNNNF)F)/__name__
__module____qualname____firstlineno____doc___USE_C_DESCRIPTORSr*   rA   rS   rV   rc   rh   rs   rw   r   r   rg   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r_   r  r  r  r  r  rN  r!  rv  r  r  r  __static_attributes__r<  r   r   r$   r$   S   s	   O>
 LQ"!H$L+('& ,FE.@b
'7>:B6/Bb($-$9"9"4<D.I0.80";"*&X5n>.eN KO37]~ HLIN2j 4924hA@J'X4("H4@5 8(r   r$   c                 <    U R                  S5      (       a  U $ SU -  $ )Nr	   rL  )
startswithr   s    r   r  r  =  s    %%754<7r   c                      [         $ r   )_DEFAULTr<  r   r   Defaultr  J  s    	/r   )r  
__author__r6   	threadingr   r\   r   r   r   google.protobuf.internalr   r   r  r   r   r"   Lockr   objectr$   r  r'   default_poolr  r  r<  r   r   <module>r     s   6 2
    & / ) < 322 D #) gV gT'8    --((r   