3
Šãde£  ã               @   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   úZ/var/www/agendate/envp3/lib/python3.6/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__1   s    zDescriptorDatabase.__init__c       
      C   s  |j }|| jkr|| j|< n | j| |kr8td| ƒ‚ndS |j}x.|jD ]$}xt||ƒD ]}| j||ƒ qZW qJW xL|jD ]B}| jdj||j fƒ|ƒ x$|j	D ]}|| j
dj||j fƒ< qžW qzW x&|jD ]}| jdj||j fƒ|ƒ qÈW x&|jD ]}	| jdj||	j fƒ|ƒ qðW 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   ÚpackageZmessage_typeÚ_ExtractSymbolsÚ
_AddSymbolÚ	enum_typeÚjoinÚvaluer   Ú	extensionÚservice)
r   Úfile_desc_protoZ
proto_namer   Úmessager   ÚenumZ
enum_valuer   r   r   r   r   ÚAdd5   s&    

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   ÚFindFileByNameW   s    z!DescriptorDatabase.FindFileByNamec             C   s\   y
| j | S  tk
rV   |jdƒ\}}}y
| j | S  tk
rP   t|ƒ‚Y nX Y nX dS )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   N)r   ÚKeyErrorÚ
rpartition)r   ÚsymbolZ	top_levelÚ_r   r   r   ÚFindFileContainingSymbolj   s    

z+DescriptorDatabase.FindFileContainingSymbolc             C   s   d S )Nr   )r   Úextendee_nameZextension_numberr   r   r   ÚFindFileContainingExtension�   s    z.DescriptorDatabase.FindFileContainingExtensionc             C   s   g S )Nr   )r   r#   r   r   r   ÚFindAllExtensionNumbers“   s    z*DescriptorDatabase.FindAllExtensionNumbersc             C   sJ   || j kr<d|j d | d | j | j d }tj|tƒ || j |< d S )NzConflict register for file "z": z is already defined in file "ú")r   r   ÚwarningsÚwarnÚRuntimeWarning)r   r   r   Z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   sn   |r|d | j  n| j }|V  x(| jD ]}xt||ƒD ]
}|V  q6W q&W x | jD ]}dj||j fƒV  qPW 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   )Z
desc_protor   Zmessage_namer*   r    r   r   r   r   r   ¡   s    
r   )	r	   Ú
__author__r'   Ú	Exceptionr   r   Úobjectr
   r   r   r   r   r   Ú<module>   s   s