o
    {j6hD                     @   sL   d Z d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 ZdS )z*Provides a container for DescriptorProtos.z"matthewtoia@google.com (Matt Toia)    Nc                   @   s   e Zd ZdS )ErrorN)__name__
__module____qualname__ r   r   r/var/www/html/chefvision.cloud.itp360.com/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                   @   sH   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dS )DescriptorDatabasezEA container accepting FileDescriptorProtos and maps DescriptorProtos.c                 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__c           
      C   s   |j }|| jvr|| j|< n| j| |krtd| dS |j}|jD ]}t||D ]}| || q*q#|jD ]}| d||j f| |j	D ]}|| j
d||j f< qHq7|jD ]}| d||j f| qZ|jD ]}	| d||	j f| qld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   file_desc_proto
proto_namer   messager   enum
enum_valuer   r   r   r   r   Add   s4   






zDescriptorDatabase.Addc                 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   FindFileByName@   s   
z!DescriptorDatabase.FindFileByNamec                 C   sT   z| j | W S  ty)   |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   KeyError
rpartition)r   symbol	top_level_r   r   r   FindFileContainingSymbolS   s   z+DescriptorDatabase.FindFileContainingSymbolc                 C   s   d S r   r   )r   extendee_nameextension_numberr   r   r   FindFileContainingExtensionx      z.DescriptorDatabase.FindFileContainingExtensionc                 C   s   g S r   r   )r   r(   r   r   r   FindAllExtensionNumbers|   r+   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   warningswarnRuntimeWarning)r   r   r   warn_msgr   r   r   r      s   

zDescriptorDatabase._AddSymbolN)r   r   r   r	   r   r    r!   r'   r*   r,   r   r   r   r   r   r
      s    "%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 )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_namer2   r$   r   r   r   r   r      s   


r   )	r	   
__author__r.   	Exceptionr   r   objectr
   r   r   r   r   r   <module>   s   s