
    gD                     \    d Z dZddlZ G d de      Z G d de      Z G d d	e      Zd
 Zy)z*Provides a container for DescriptorProtos.z"matthewtoia@google.com (Matt Toia)    Nc                       e Zd Zy)ErrorN)__name__
__module____qualname__     X/var/www/openai/venv/lib/python3.12/site-packages/google/protobuf/descriptor_database.pyr   r      s    r	   r   c                       e Zd ZdZy),DescriptorDatabaseConflictingDefinitionErrorzGRaised when a proto is added with the same name & different descriptor.N)r   r   r   __doc__r   r	   r
   r   r      s    Or	   r   c                   :    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
y	)
DescriptorDatabasezEA container accepting FileDescriptorProtos and maps DescriptorProtos.c                      i | _         i | _        y N)_file_desc_protos_by_file_file_desc_protos_by_symbol)selfs    r
   __init__zDescriptorDatabase.__init__   s    %'D"')D$r	   c                    |j                   }|| j                  vr|| j                  |<   n!| j                  |   |k7  rt        d|z        y|j                  }|j                  D ]%  }t        ||      D ]  }| j                  ||        ' |j                  D ]j  }| j                  dj                  ||j                   f      |       |j                  D ],  }|| j                  dj                  ||j                   f      <   . l |j                  D ]/  }| j                  dj                  ||j                   f      |       1 |j                  D ]/  }	| j                  dj                  ||	j                   f      |       1 y)aL  Adds the FileDescriptorProto and its types to this database.

    Args:
      file_desc_proto: The FileDescriptorProto to add.
    Raises:
      DescriptorDatabaseConflictingDefinitionError: if an attempt is made to
        add a proto with the same name but different definition than an
        existing proto in the database.
    z0%s already added, but with different descriptor.N.)namer   r   packagemessage_type_ExtractSymbols
_AddSymbol	enum_typejoinvaluer   	extensionservice)
r   file_desc_proto
proto_namer   messager   enum
enum_valuer    r!   s
             r
   AddzDescriptorDatabase.Add   sb    !%%J7773Bd$$Z0		'	'
	3	F8
<z
IK K  %%G"//!'73$o. 4 0  ))
oosxx$)) 45H

*4C 	((HHgz/0	2 # *
 %..	
oosxx).. 9:_M /"**
oosxx',, 78?K +r	   c                      | j                   |   S )a  Finds the file descriptor proto by file name.

    Typically the file name is a relative path ending to a .proto file. The
    proto with the given name will have to have been added to this database
    using the Add method or else an error will be raised.

    Args:
      name: The file name to find.

    Returns:
      The file descriptor proto matching the name.

    Raises:
      KeyError if no file by the given name was added.
    )r   )r   r   s     r
   FindFileByNamez!DescriptorDatabase.FindFileByName@   s    " ))$//r	   c                     	 | j                   |   S # t        $ r@ |j                  d      \  }}}	 | j                   |   cY S # t        $ r t        |      w xY ww xY w)a  Finds the file descriptor proto containing the specified symbol.

    The symbol should be a fully qualified name including the file descriptor's
    package and any containing messages. Some examples:

    'some.package.name.Message'
    'some.package.name.Message.NestedEnum'
    'some.package.name.Message.some_field'

    The file descriptor proto containing the specified symbol must be added to
    this database using the Add method or else an error will be raised.

    Args:
      symbol: The fully qualified symbol name.

    Returns:
      The file descriptor proto containing the symbol.

    Raises:
      KeyError if no file contains the specified symbol.
    r   )r   KeyError
rpartition)r   symbol	top_level_s       r
   FindFileContainingSymbolz+DescriptorDatabase.FindFileContainingSymbolS   so    ,--f55  ))#.oiA//	:: vs    AAAAAc                      y r   r   )r   extendee_nameextension_numbers      r
   FindFileContainingExtensionz.DescriptorDatabase.FindFileContainingExtensionx   s    r	   c                     g S r   r   )r   r2   s     r
   FindAllExtensionNumbersz*DescriptorDatabase.FindAllExtensionNumbers|   s    Ir	   c                     || j                   v rOd|j                  z   dz   |z   dz   | j                   |   j                  z   dz   }t        j                  |t               || j                   |<   y )NzConflict register for file "z": z is already defined in file "")r   r   warningswarnRuntimeWarning)r   r   r"   warn_msgs       r
   r   zDescriptorDatabase._AddSymbol   s    t///0?3G3GG12 2248==> ADDh mmHn--<D$$T*r	   N)r   r   r   r   r   r'   r)   r0   r4   r6   r   r   r	   r
   r   r      s+    M* LD0&#J=r	   r   c              #      K   |r|dz   | j                   z   n| j                   }| | j                  D ]  }t        ||      D ]  }|   | j                  D ]!  }dj	                  ||j                   f       # yw)zPulls out all the symbols from a descriptor proto.

  Args:
    desc_proto: The proto to extract symbols from.
    package: The package containing the descriptor type.

  Yields:
    The fully qualified name found in the descriptor.
  r   N)r   nested_typer   r   r   )
desc_protor   message_namer>   r-   r   s         r
   r   r      sx      5<30,++k!+|<l = , ''i
((L)..1
22 (s   A<A>)	r   
__author__r9   	Exceptionr   r   objectr   r   r   r	   r
   <module>rD      s@    11
 I P5 Pp= p=f3r	   