Spade
Mini Shell
| Directory:~$ /proc/self/root/usr/lib/python2.7/site-packages/google/protobuf/ |
| [Home] [System Details] [Kill Me] |
�
Q�,Qc@sVdZdZddlmZddlmZddlmZdefd��YZdS( s�Provides
DescriptorPool to use as a container for proto2 descriptors.
The DescriptorPool is used in conjection with a DescriptorDatabase to
maintain
a collection of protocol buffer descriptors for use when dynamically
creating
message types at runtime.
For most applications protocol buffers should be used via modules generated
by
the protocol buffer compiler tool. This should only be used when the type
of
protocol buffers used in an application or library cannot be predetermined.
Below is a straightforward example on how to use this class:
pool = DescriptorPool()
file_descriptor_protos = [ ... ]
for file_descriptor_proto in file_descriptor_protos:
pool.Add(file_descriptor_proto)
my_message_descriptor =
pool.FindMessageTypeByName('some.package.MessageType')
The message descriptor can be used in conjunction with the message_factory
module in order to create a protocol buffer class that can be encoded and
decoded.
s"matthewtoia@google.com (Matt Toia)i����(tdescriptor_pb2(t
descriptor(tdescriptor_databasetDescriptorPoolcBs�eZdZdd�Zd�Zd�Zd�Zd�Zd�Z d�Z
dddd�Zddddd �Ze
d
�Zd�Zd�Zd
�Zd�Zd�Zd�ZRS(sGA collection of
protobufs dynamically constructed by descriptor
protos.cCs7tj�|_||_i|_i|_i|_dS(s�Initializes a Pool of
proto buffs.
The descriptor_db argument to the constructor is provided to allow
specialized file descriptor proto lookup code to be triggered on
demand. An
example would be an implementation which will read and compile a file
specified in a call to FindFileByName() and not require the call to
Add()
at all. Results from this database will be cached internally here as
well.
Args:
descriptor_db: A secondary source of file descriptors.
N(RtDescriptorDatabaset_internal_dbt_descriptor_dbt_descriptorst_enum_descriptorst_file_descriptors(tselft
descriptor_db((sC/usr/lib/python2.7/site-packages/google/protobuf/descriptor_pool.pyt__init__@s
cCs|jj|�dS(sAdds the FileDescriptorProto and its
types to this pool.
Args:
file_desc_proto: The FileDescriptorProto to add.
N(RtAdd(R
tfile_desc_proto((sC/usr/lib/python2.7/site-packages/google/protobuf/descriptor_pool.pyR
SscCsvy|jj|�}Wn7tk
rO}|jrF|jj|�}qP|�nX|sitd|��n|j|�S(s�Gets
a FileDescriptor by file name.
Args:
file_name: The path to the file to get a descriptor for.
Returns:
A FileDescriptor for the named file.
Raises:
KeyError: if the file can not be found in the pool.
sCannot find a file named
%s(RtFindFileByNametKeyErrorRt!_ConvertFileProtoToFileDescriptor(R
t file_namet
file_prototerror((sC/usr/lib/python2.7/site-packages/google/protobuf/descriptor_pool.pyR\s
cCsvy|jj|�}Wn7tk
rO}|jrF|jj|�}qP|�nX|sitd|��n|j|�S(sGets
the FileDescriptor for the file containing the specified symbol.
Args:
symbol: The name of the symbol to search for.
Returns:
A FileDescriptor that contains the specified symbol.
Raises:
KeyError: if the file can not be found in the pool.
s Cannot find a file containing
%s(RtFindFileContainingSymbolRRR(R
tsymbolRR((sC/usr/lib/python2.7/site-packages/google/protobuf/descriptor_pool.pyRts
cCs9|jd�}||jkr.|j|�n|j|S(s�Loads the named
descriptor from the pool.
Args:
full_name: The full name of the descriptor to load.
Returns:
The descriptor for the named type.
t.(tlstripRR(R
t full_name((sC/usr/lib/python2.7/site-packages/google/protobuf/descriptor_pool.pytFindMessageTypeByName�s
cCs9|jd�}||jkr.|j|�n|j|S(s�Loads the named
enum descriptor from the pool.
Args:
full_name: The full name of the enum descriptor to load.
Returns:
The enum descriptor for the named type.
R(RRR(R
R((sC/usr/lib/python2.7/site-packages/google/protobuf/descriptor_pool.pytFindEnumTypeByName�s
c sC|j|jkr5tjd|jd|jd|jd|j��}i}t|j|��}x�|D]�}|j |j�}t
jj|j
�}d|j}|d��fd��t|j|j|��} |j| �|j�fd�| D��t|j|j|��} |j| �|j�fd�| D��qgWx<|jD]1}
|j|
|j||�}||j|j<qRWx-|jD]"}|j||j|d |�q�Wx*|j|j�D]}
|j|
|�q�Wx.|jD]#}
||
j}||j|
j<q�W|j|�||j|j<n|j|jS(
sDCreates a FileDescriptor from a proto or returns a cached copy.
This method also has the side effect of loading all the symbols found
in
the file into the appropriate dictionaries in the pool.
Args:
file_proto: The proto to convert.
Returns:
A FileDescriptor matching the passed in proto.
tnametpackagetoptionst
serialized_pbRcs!|j��r|t��S|S(N(t
startswithtlen(R(tpackage_prefix(sC/usr/lib/python2.7/site-packages/google/protobuf/descriptor_pool.pyt_strip_package�sc3s'|]\}}�|�|fVqdS(N((t.0tktv(R#(sC/usr/lib/python2.7/site-packages/google/protobuf/descriptor_pool.pys <genexpr>�sc3s'|]\}}�|�|fVqdS(N((R$R%R&(R#(sC/usr/lib/python2.7/site-packages/google/protobuf/descriptor_pool.pys <genexpr>�sN(RR RtFileDescriptorRRtSerializeToStringtlistt_GetDepsRRtFileDescriptorProtot
FromStringRt_ExtractSymbolstmessage_typetupdatet
_ExtractEnumst enum_typet_ConvertMessageDescriptortmessage_types_by_namet_ConvertEnumDescriptortNonet_ExtractMessagest_SetFieldTypesR
(R
Rtfile_descriptortscopetdependenciest
dependencytdep_desct dep_protoRtsymbolsR.tmessage_descR1t
desc_prototdesc((R#R"sC/usr/lib/python2.7/site-packages/google/protobuf/descriptor_pool.pyR�sH
!
cCs3|r!dj||jf�}n |j}|dkr?d}n |j}|dkr]i}ng|jD]}|j||||�^qg}g|jD]!}|j|||d|�^q�} gt|j�D]!\}
}|j |||
�^q�}gt|j
�D]!\}
}
|j |
|t�^q}g|jD]}|j
|jf^q4}|rat}nt}tjd|jd|d|ddd|d|d| d |d
|jd|d|d
|dddd�}x|jD]}||_q�Wx|jD]}||_q�W|||j<||d|<||j|<|S(soAdds
the proto to the pool in the specified package.
Args:
desc_proto: The descriptor_pb2.DescriptorProto protobuf message.
package: The package the proto should be located in.
file_desc: The file containing this message.
scope: Dict mapping short and full symbols to message and enum types.
Returns:
The added descriptor.
RRRtfilenametcontaining_typetfieldstnested_typest
enum_typest
extensionsRt
is_extendabletextension_rangestfiletserialized_starttserialized_endN(tjoinRR5tnested_typeR2R1R4t enumeratetfieldt_MakeFieldDescriptort extensiontTruetextension_rangetstarttendtFalseRt
DescriptorRRERCRFR(R
R@Rt file_descR9t desc_nameRtnestedtenumtenumstindexRPRDRRRGtrRIRHRA((sC/usr/lib/python2.7/site-packages/google/protobuf/descriptor_pool.pyR2�sV +.44(
cCs�|r!dj||jf�}n |j}|d
kr?d
}n |j}gt|j�D]\}} |j| |�^qX}
tjd|jd|d|d|d|
d|d|j�}|||j<||d |<||j |<|S(s�Make a
protobuf EnumDescriptor given an EnumDescriptorProto protobuf.
Args:
enum_proto: The descriptor_pb2.EnumDescriptorProto protobuf message.
package: Optional package name for the new message EnumDescriptor.
file_desc: The file containing the enum descriptor.
containing_type: The type containing this enum.
scope: Scope containing available types.
Returns:
The added descriptor
RRRRBRJtvaluesRCRs.%sN(
RMRR5ROtvaluet_MakeEnumValueDescriptorRtEnumDescriptorRR(R
t
enum_protoRRYRCR9t enum_nameRR^RaR`RA((sC/usr/lib/python2.7/site-packages/google/protobuf/descriptor_pool.pyR4(s& 1
cCs�|r!dj||jf�}n |j}tjd|jd|d|d|jd|jddddd dd
dd|jdtd
dd|ddd|j �S(shCreates a field descriptor from a
FieldDescriptorProto.
For message and enum type fields, this method will do a look up
in the pool for the appropriate descriptor for that type. If it
is unavailable, it will fall back to the _source function to
create it. If this type is still unavailable, construction will
fail.
Args:
field_proto: The proto describing the field.
message_name: The name of the containing message.
index: Index of the field
is_extension: Indication that this field is for an extension.
Returns:
An initialized FieldDescriptor object
RRRR^tnumberttypetcpp_typeR.R1RCtlabelthas_default_valuet
default_valuetis_extensiontextension_scopeRN(
RMRRtFieldDescriptorRfRgR5RiRWR(R
tfield_prototmessage_nameR^RlR((sC/usr/lib/python2.7/site-packages/google/protobuf/descriptor_pool.pyRQOs& cCs�||j}xNt|j|j�D]7\}}|jrg|j}||krZd|}n||}nd}|jd�s�t|tj �r�tj
j|_q�tj
j
|_ntj
j|j�|_|jtj
jks�|jtj
jkr||_n|jtj
j
kr!||_n|jtj
jkrKt|_g|_n|jd�r<t|_|jtj
jks�|jtj
jkr�t|j�|_qN|jtj
jkr�|j|_qN|jtj
jkr�|jj�dk|_qN|jtj
j
kr'|jj|jj
|_qNt!|j�|_nt|_d|_|j|_q#Wx!|j"D]}|j#||�qhWdS(s�Sets
the field's type, cpp_type, message_type and enum_type.
Args:
desc_proto: The message descriptor to update.
scope: Enclosing scope of available types.
RRgRkttrueN($RtzipRPRDt type_nameR5tHasFieldt
isinstanceRRXRntTYPE_MESSAGERgt TYPE_ENUMtProtoTypeToCppProtoTypeRht
TYPE_GROUPR.R1RitLABEL_REPEATEDRWthas_defaultRkRStTYPE_DOUBLEt
TYPE_FLOATtfloattTYPE_STRINGt TYPE_BOOLtlowertvalues_by_nameR^tintRNR7(R
R@R9RARot
field_descRsRN((sC/usr/lib/python2.7/site-packages/google/protobuf/descriptor_pool.pyR7ysP
"
cCs1tjd|jd|d|jd|jdd�S(s�Creates
a enum value descriptor object from a enum value proto.
Args:
value_proto: The proto describing the enum value.
index: The index of the enum value.
Returns:
An initialized EnumValueDescriptor object.
RR^RfRRgN(RtEnumValueDescriptorRRfRR5(R
tvalue_protoR^((sC/usr/lib/python2.7/site-packages/google/protobuf/descriptor_pool.pyRb�s ccs�x�|D]�}|r.dj||jf�}n |j}|j|�}||fVx"|j|j|�D]}|VqgWx"|j|j|�D]}|Vq�WqWdS(sPulls
out all the symbols from descriptor protos.
Args:
desc_protos: The protos to extract symbols from.
package: The package containing the descriptor type.
Yields:
A two element tuple of the type name and descriptor object.
RN(RMRRR-RNR0R1(R
tdesc_protosRR@RpR?R((sC/usr/lib/python2.7/site-packages/google/protobuf/descriptor_pool.pyR-�s
ccsYxR|D]J}|r.dj||jf�}n |j}|j|�}||fVqWdS(s�Pulls
out all the symbols from enum protos.
Args:
enum_protos: The protos to extract symbols from.
package: The package containing the enum type.
Yields:
A two element tuple of the type name and enum descriptor object.
RN(RMRR(R
tenum_protosRRdRet enum_desc((sC/usr/lib/python2.7/site-packages/google/protobuf/descriptor_pool.pyR0�s
ccs<x5|D]-}|Vx|j|j�D]}|Vq%WqWdS(s�Pulls
out all the message protos from descriptos.
Args:
desc_protos: The protos to extract symbols from.
Yields:
Descriptor protos.
N(R6RN(R
R�R@tmessage((sC/usr/lib/python2.7/site-packages/google/protobuf/descriptor_pool.pyR6�s
ccs`xY|jD]N}|j|�}tjj|j�}|Vx|j|�D]}|VqIWq
WdS(s�Recursively finds dependencies for file protos.
Args:
file_proto: The proto to get dependencies from.
Yields:
Each direct and indirect dependency.
N(R;RRR+R,RR*(R
RR;R<R=t
parent_dep((sC/usr/lib/python2.7/site-packages/google/protobuf/descriptor_pool.pyR*�s
N(t__name__t
__module__t__doc__R5RR
RRRRRR2R4RWRQR7RbR-R0R6R*(((sC/usr/lib/python2.7/site-packages/google/protobuf/descriptor_pool.pyR=s& <A') < N(R�t
__author__tgoogle.protobufRRRtobjectR(((sC/usr/lib/python2.7/site-packages/google/protobuf/descriptor_pool.pyt<module>4s