� S�Ljc @ s� d Z y d d l m Z Wn! e k r= d d l m Z n Xd d l Z d d l Z d d l m Z d d l m Z d � Z d d d � Z d � Z d S( s Dynamic Protobuf class creator.i����( t OrderedDictN( t descriptor_pb2( t message_factoryc C s% | j j | � } | j | � } | S( s8 Get a proto class from the MessageFactory by name. Args: factory: a MessageFactory instance. full_name: str, the fully qualified name of the proto type. Returns: A class, for the type identified by full_name. Raises: KeyError, if the proto is not found in the factory's descriptor pool. ( t poolt FindMessageTypeByNamet GetPrototype( t factoryt full_namet proto_descriptort proto_cls( ( sA /usr/lib/python2.7/site-packages/google/protobuf/proto_builder.pyt _GetMessageFromFactory, s c C sN t j d | � } | d k rL y t | | � } | SWqL t k rH qL Xn | j � } t | t � sv t | � } n t j � } xF | D]> \ } } | j | j d � � | j t | � j d � � q� W| j � d } | d k r%d | j � } y t | | � } | SWq%t k r!q%Xn | j j t | | | � � t | | � S( s� Create a Protobuf class whose fields are basic types. Note: this doesn't validate field names! Args: fields: dict of {name: field_type} mappings for each field in the proto. If this is an OrderedDict the order will be maintained, otherwise the fields will be sorted by name. full_name: optional str, the fully-qualified name of the proto type. pool: optional DescriptorPool instance. Returns: a class, the new protobuf class with a FileDescriptor. R s utf-8s .protos6 net.proto2.python.public.proto_builder.AnonymousProto_N( R t MessageFactoryt NoneR t KeyErrort itemst isinstanceR t sortedt hashlibt sha1t updatet encodet strt hexdigestR t Addt _MakeFileDescriptorProto( t fieldsR R R R t field_itemst fields_hasht f_namet f_typet proto_file_name( ( sA /usr/lib/python2.7/site-packages/google/protobuf/proto_builder.pyt MakeSimpleProtoClass<