Your IP : 13.58.199.206
�
Du�ac@shdZdZddlmZddlmZddlmZdefd��YZe�Zd�Z d S(
soProvides a factory class for generating dynamic messages.
The easiest way to use this class is if you have access to the FileDescriptor
protos containing the messages you want to create you can just do the following:
message_classes = message_factory.GetMessages(iterable_of_file_descriptors)
my_proto_instance = message_classes['some.proto.package.MessageName']()
s"matthewtoia@google.com (Matt Toia)i����(tdescriptor_pool(tmessage(t
reflectiontMessageFactorycBs,eZdZdd�Zd�Zd�ZRS(s@Factory for creating Proto2 messages from descriptors in a pool.cCs"|ptj�|_i|_dS(sInitializes a new factory.N(RtDescriptorPooltpoolt_classes(tselfR((sC/usr/lib/python2.7/site-packages/google/protobuf/message_factory.pyt__init__2scCs ||jkr�|j}ttkr<|jjdd�}ntj|tjfi|d6dd6�}||j|<x-|j
D]"}|jr||j|j�q|q|WxY|j
jD]H}|j|jkr�|j|j�n|j|j}|j|�q�Wn|j|S(sDBuilds 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.
tasciitignoret
DESCRIPTORt
__module__N(RtnametstrtbytestencodeRtGeneratedProtocolMessageTypeRtMessagetNonetfieldstmessage_typetGetPrototypeRt
extensionstcontaining_typetRegisterExtension(Rt
descriptortdescriptor_nametresult_classtfieldt extensiontextended_class((sC/usr/lib/python2.7/site-packages/google/protobuf/message_factory.pyR9s$
cCs�i}x�|D]�}|jj|�}x-|jj�D]}|j|�||j<q5WxY|jj�D]H}|j|jkr�|j|j�n|j|j}|j |�qeWq
W|S(s�Gets all the messages from a specified file.
This will find and resolve dependencies, failing if the descriptor
pool cannot satisfy them.
Args:
files: The file names to extract messages from.
Returns:
A dictionary mapping proto names to the message classes. This will include
any dependent messages as well as any messages defined in the same file as
a specified message.
(
RtFindFileByNametmessage_types_by_nametvaluesRt full_nametextensions_by_nameRRR(Rtfilestresultt file_namet file_desctdescRR((sC/usr/lib/python2.7/site-packages/google/protobuf/message_factory.pytGetMessagesYs
N(t__name__Rt__doc__RRRR*(((sC/usr/lib/python2.7/site-packages/google/protobuf/message_factory.pyR/s csfd�|D����fd��x�rB��j�d�q%Wtjg|D]}|j^qP�S(s^Builds a dictionary of all the messages available in a set of files.
Args:
file_protos: Iterable of FileDescriptorProto to build messages out of.
Returns:
A dictionary mapping proto names to the message classes. This will include
any dependent messages as well as any messages defined in the same file as
a specified message.
cSsi|]}||j�qS((R
(t.0t
file_proto((sC/usr/lib/python2.7/site-packages/google/protobuf/message_factory.pys
<dictcomp>�s csJx3|jD](}|�kr
��j|��q
q
Wtjj|�dS(N(t
dependencytpopt_FACTORYRtAdd(R.R/(t_AddFiletfile_by_name(sC/usr/lib/python2.7/site-packages/google/protobuf/message_factory.pyR3�si(tpopitemR1R*R
(tfile_protosR.((R3R4sC/usr/lib/python2.7/site-packages/google/protobuf/message_factory.pyR*�s
N(
R,t
__author__tgoogle.protobufRRRtobjectRR1R*(((sC/usr/lib/python2.7/site-packages/google/protobuf/message_factory.pyt<module>&sO
?>