ķ
Q÷,Qc           @   s   d  Z  d Z d d l m Z d d l m Z d d l m Z d d l m Z d e f d     YZ e j	   Z
 e j e
  Z e   Z d	   Z d
   Z d S(   s9   Provides a factory class for generating dynamic messages.s"   matthewtoia@google.com (Matt Toia)i˙˙˙˙(   t   descriptor_database(   t   descriptor_pool(   t   message(   t
   reflectiont   MessageFactoryc           B   s    e  Z d  Z d   Z d   Z RS(   s@   Factory for creating Proto2 messages from descriptors in a pool.c         C   s   i  |  _  d S(   s   Initializes a new factory.N(   t   _classes(   t   self(    (    sC   /usr/lib/python2.7/site-packages/google/protobuf/message_factory.pyt   __init__,   s    c         C   s   | j  |  j k r t j | j j d d  t j f i | d 6 } | |  j | j  <x0 | j D]" } | j	 r] |  j
 | j	  q] q] Wn  |  j | j  S(   sD  Builds a proto2 message class based on the passed in descriptor.

    Passing a descriptor with a fully qualified name matching a previous
    invocation will cause the same class to be returned.

    Args:
      descriptor: The descriptor to build from.

    Returns:
      A class describing the passed in descriptor.
    t   asciit   ignoret
   DESCRIPTOR(   t	   full_nameR   R   t   GeneratedProtocolMessageTypet   namet   encodeR   t   Messaget   fieldst   message_typet   GetPrototype(   R   t
   descriptort   result_classt   field(    (    sC   /usr/lib/python2.7/site-packages/google/protobuf/message_factory.pyR   0   s    		(   t   __name__t
   __module__t   __doc__R   R   (    (    (    sC   /usr/lib/python2.7/site-packages/google/protobuf/message_factory.pyR   )   s   	c         C   so   i  } x |  D] } t  j |  q WxD |  D]< } x3 t | j | j  D] } t j |  | | j <qG Wq+ W| S(   s/  Builds a dictionary of all the messages available in a set of files.

  Args:
    file_protos: A sequence of file protos to build messages out of.

  Returns:
    A dictionary containing all the message types in the files mapping the
    fully qualified name to a Message subclass for the descriptor.
  (   t   _DBt   Addt   _GetAllDescriptorsR   t   packaget   _FACTORYR   R   (   t   file_protost   resultt
   file_protot   desc(    (    sC   /usr/lib/python2.7/site-packages/google/protobuf/message_factory.pyt   GetMessagesN   s    c         c   s]   xV |  D]N } d j  | | j f  } t j |  Vx t | j |  D] } | VqF Wq Wd S(   sū   Gets all levels of nested message types as a flattened list of descriptors.

  Args:
    desc_protos: The descriptor protos to process.
    package: The package where the protos are defined.

  Yields:
    Each message descriptor for each nested type.
  t   .N(   t   joinR   t   _POOLt   FindMessageTypeByNameR   t   nested_type(   t   desc_protosR   t
   desc_protoR   t   nested_desc(    (    sC   /usr/lib/python2.7/site-packages/google/protobuf/message_factory.pyR   b   s
    N(   R   t
   __author__t   google.protobufR    R   R   R   t   objectR   t   DescriptorDatabaseR   t   DescriptorPoolR%   R   R"   R   (    (    (    sC   /usr/lib/python2.7/site-packages/google/protobuf/message_factory.pyt   <module>   s    		