� S�Ljc@s�dZyddlmZWn!ek r=ddlmZnXddlZddlZddlmZddlm Z d�Z ddd�Z d�Z dS( sDynamic Protobuf class creator.i����(t OrderedDictN(tdescriptor_pb2(tmessage_factorycCs%|jj|�}|j|�}|S(s8Get 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. (tpooltFindMessageTypeByNamet GetPrototype(tfactoryt full_nametproto_descriptort proto_cls((sA/usr/lib/python2.7/site-packages/google/protobuf/proto_builder.pyt_GetMessageFromFactory,s c CsNtjd|�}|dk rLyt||�}|SWqLtk rHqLXn|j�}t|t�svt|�}nt j �}xF|D]>\}}|j |j d��|j t |�j d��q�W|j�d} |dkr%d|j�}yt||�}|SWq%tk r!q%Xn|jjt| ||��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. Rsutf-8s.protos6net.proto2.python.public.proto_builder.AnonymousProto_N(RtMessageFactorytNoneR tKeyErrortitemst isinstanceRtsortedthashlibtsha1tupdatetencodetstrt hexdigestRtAddt_MakeFileDescriptorProto( tfieldsRRRR t field_itemst fields_hashtf_nametf_typetproto_file_name((sA/usr/lib/python2.7/site-packages/google/protobuf/proto_builder.pytMakeSimpleProtoClass<s4         c Cs�|jdd�\}}tj�}tjj|jdd�|�|_||_|j j �}||_x\t |d�D]K\}\}} |j j �} || _|| _ tjj| _| | _qyW|S(sAPopulate FileDescriptorProto for MessageFactory's DescriptorPool.t.it/(trsplitRtFileDescriptorPrototostpathtjointreplacetnametpackaget message_typetaddt enumeratetfieldtnumbertFieldDescriptorPrototLABEL_OPTIONALtlabelttype( RRRR)R(t file_protot desc_prototf_numberRRt field_proto((sA/usr/lib/python2.7/site-packages/google/protobuf/proto_builder.pyRts $  "   (t__doc__t collectionsRt ImportErrort ordereddictRR$tgoogle.protobufRRR R RR(((sA/usr/lib/python2.7/site-packages/google/protobuf/proto_builder.pyts    8