ó
X¾÷Xc           @   s[   d  Z  d Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z d	 S(
   s*   Provides a container for DescriptorProtos.s"   matthewtoia@google.com (Matt Toia)t   Errorc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sE   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/descriptor_database.pyR    $   s   t,   DescriptorDatabaseConflictingDefinitionErrorc           B   s   e  Z d  Z RS(   sG   Raised when a proto is added with the same name & different descriptor.(   R   R   t   __doc__(    (    (    sE   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/descriptor_database.pyR   (   s   t   DescriptorDatabasec           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   sE   A container accepting FileDescriptorProtos and maps DescriptorProtos.c         C   s   i  |  _  i  |  _ d  S(   N(   t   _file_desc_protos_by_filet   _file_desc_protos_by_symbol(   t   self(    (    sE   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/descriptor_database.pyt   __init__/   s    	c            sþ   ˆ  j  } | |  j k r( ˆ  |  j | <n& |  j | ˆ  k rN t d | ƒ ‚ n  ˆ  j } x: ˆ  j D]/ } |  j j ‡  f d †  t | | ƒ Dƒ ƒ qa Wx0 ˆ  j D]% } ˆ  |  j d j	 | | j  f ƒ <qž Wx0 ˆ  j
 D]% } ˆ  |  j d j	 | | j  f ƒ <qÑ Wd S(   s<  Adds the FileDescriptorProto and its types to this database.

    Args:
      file_desc_proto: The FileDescriptorProto to add.
    Raises:
      DescriptorDatabaseException: if an attempt is made to add a proto
        with the same name but different definition than an exisiting
        proto in the database.
    s0   %s already added, but with different descriptor.c         3   s   |  ] } | ˆ  f Vq d  S(   N(    (   t   .0t   name(   t   file_desc_proto(    sE   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/descriptor_database.pys	   <genexpr>H   s    t   .N(   R   R   R   t   packaget   message_typeR   t   updatet   _ExtractSymbolst	   enum_typet   joint	   extension(   R   R   t
   proto_nameR   t   messaget   enumR   (    (   R   sE   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/descriptor_database.pyt   Add3   s    
			$#c         C   s   |  j  | S(   s¸  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   (    (    sE   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/descriptor_database.pyt   FindFileByNameP   s    c         C   s   |  j  | S(   sw  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'

    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   t   symbol(    (    sE   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/descriptor_database.pyt   FindFileContainingSymbolc   s    (   R   R   R   R	   R   R   R   (    (    (    sE   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/descriptor_database.pyR   ,   s
   			c         c   s   d j  | |  j f ƒ } | Vx0 |  j D]% } x t | | ƒ D] } | Vq= Wq' Wx( |  j D] } d j  | | j f ƒ VqZ Wd S(   së   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   R   t   nested_typeR   R   (   t
   desc_protoR   t   message_nameR   R   R   (    (    sE   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/descriptor_database.pyR   |   s    N(   R   t
   __author__t	   ExceptionR    R   t   objectR   R   (    (    (    sE   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/descriptor_database.pyt   <module>   s
   P