ó Du—ac@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