o
    ë6Wj�  ã                   @   sr   d Z dZddlmZmZmZ ddlZG dd„ deƒZG dd„ deƒZ	G d	d
„ d
e
ƒZdddedee fdd„ZdS )z*Provides a container for DescriptorProtos.z"matthewtoia@google.com (Matt Toia)é    )ÚDictÚIteratorÚOptionalNc                   @   s   e Zd ZdS )ÚErrorN)Ú__name__Ú
__module__Ú__qualname__© r	   r	   úr/home/esfera/Documents/content_generation/venv/lib/python3.10/site-packages/google/protobuf/descriptor_database.pyr      s    r   c                   @   s   e Zd ZdZdS )Ú,DescriptorDatabaseConflictingDefinitionErrorzGRaised when a proto is added with the same name & different descriptor.N)r   r   r   Ú__doc__r	   r	   r	   r
   r      s    r   c                   @   sŽ   e Zd ZdZddd„Zddd	„Zd
eddfdd„Zdeddfdd„Zdede	de
d fdd„Zdedee	 fdd„Zd
eddddfdd„ZdS )ÚDescriptorDatabasezEA container accepting FileDescriptorProtos and maps DescriptorProtos.ÚreturnNc                 C   s   i | _ i | _d S ©N)Ú_file_desc_protos_by_fileÚ_file_desc_protos_by_symbol)Úselfr	   r	   r
   Ú__init__   s   þþzDescriptorDatabase.__init__Úfile_desc_protoú"descriptor_pb2.FileDescriptorProtoc           
      C   s"  |j }|| jvr|| j|< n| j| |krtd| ƒ‚dS |j}|jD ]}t||ƒD ]}|  ||¡ q*q#|jD ])}|  |rEd ||j f¡n|j |¡ |j	D ]}|| j
|r\d ||j f¡n|j < qMq7|jD ]}|  |rrd ||j f¡n|j |¡ qd|jD ]}	|  |r‰d ||	j f¡n|	j |¡ q{dS )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   r   Ú
proto_namer   Úmessager   ÚenumÚ
enum_valuer   r    r	   r	   r
   ÚAdd#   sF   

ÿ
ÿ
þ
þÿÿ
þ
þÿzDescriptorDatabase.Addr   c                 C   s
   | 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   r	   r	   r
   ÚFindFileByNameO   s   
z!DescriptorDatabase.FindFileByNameÚsymbolc                 C   s„   |  d¡dkr|d dkr| d¡}t dt¡ z| j| W S  tyA   | d¡\}}}z| j| W  Y S  ty@   t|ƒ‚w 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   zaPlease remove the leading "." when FindFileContainingSymbol, this will turn to error in 2026 Jan.)ÚcountÚlstripÚwarningsÚwarnÚRuntimeWarningr   ÚKeyErrorÚ
rpartition)r   r'   Ú	top_levelÚ_r	   r	   r
   ÚFindFileContainingSymbolb   s    
üþ÷z+DescriptorDatabase.FindFileContainingSymbolÚextendee_nameÚextension_numberc                 C   s   d S r   r	   )r   r3   r4   r	   r	   r
   ÚFindFileContainingExtension‘   s   z.DescriptorDatabase.FindFileContainingExtensionc                 C   s   g S r   r	   )r   r3   r	   r	   r
   ÚFindAllExtensionNumbers—   s   z*DescriptorDatabase.FindAllExtensionNumbersc                 C   sJ   || j v rd|j d | d | j | j d }t |t¡ || j |< d S )NzConflict register for file "z": z is already defined in file "ú")r   r   r+   r,   r-   )r   r   r   Úwarn_msgr	   r	   r
   r   ›   s   
ÿÿþ
ýýzDescriptorDatabase._AddSymbol)r   N)r   r   r   N)r   r   r   r   r   r%   Ústrr&   r2   Úintr   r5   Úlistr6   r   r	   r	   r	   r
   r      s2    

,ÿ
þ/ÿÿ
þÿÿþr   Ú
desc_protozdescriptor_pb2.DescriptorProtor   r   c                 c   sd   � |r
|d | j  n| j }|V  | jD ]}t||ƒD ]}|V  qq| jD ]}d ||j f¡V  q$dS )zëPulls 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   )r<   r   Úmessage_namer=   r'   r   r	   r	   r
   r   §   s   €
ÿ
ÿr   )r   Ú
__author__Útypingr   r   r   r+   Ú	Exceptionr   r   Úobjectr   r9   r   r	   r	   r	   r
   Ú<module>   s    ÿÿþ