� S�Ljc@s�dZdZddlZddlZejr6eZnddlmZddlm Z ddlm Z ddlm Z ddl m Z e jZd �Zd �Zd efd ��YZd efd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZie�ej6e�ej6e�ej6e�ej6edej �ej!6edej �ej"6ee#e$ej%�ej&6ede'�ej(6Z)ie j*ej+6e j,ej-6e j.ej/6e j0ej16e j2ej36e j4ej56e j6ej76e j8ej96e j:ej;6e j<ej=6e j>ej?6e j@ejA6e jBejC6e jDejE6e jFejG6e jHejI6e jJejK6e jLejM6ZNie jOej+6e jPej-6e jQej/6e jRej16e jSej36e jTej56e jUej76e jVej96e jWej;6e jXej=6e jYej?6e jZejA6e j[ejC6e j\ejE6e j]ejG6e j^ejI6e j_ejK6e j`ejM6Zaie jbej+6e jcej-6e jdej/6e jeej16e jfej36e jgej56e jhej76e jiej96e jjej;6e jkej=6e jlej?6e jmejA6e jnejC6e joejE6e jpejG6e jqejI6e jrejK6e jsejM6Ztie juej+6e jvej-6e jwej/6e jxej16e jyej36e jzej56e j{ej76e j|ej96e j}ej;6e j~ej=6e jej?6e j�ejA6e j�ejC6e j�ejE6e j�ejG6e j�ejI6e j�ejK6e j�ejM6Z�ie j�ej+6e j�ej-6e j�ej/6e j�ej16e j�ej36e j�ej56e j�ej76e j�ej96e j�ej;6e j�ej=6e j�ej?6e j�ejA6e j�ejC6e j�ejE6e j�ejG6e j�ejI6e j�ejK6e j�ejM6Z�dS(sProvides type checking routines. This module defines type checking utilities in the forms of dictionaries: VALUE_CHECKERS: A dictionary of field types and a value validation object. TYPE_TO_BYTE_SIZE_FN: A dictionary with field types and a size computing function. TYPE_TO_SERIALIZE_METHOD: A dictionary with field types and serialization function. FIELD_TYPE_TO_WIRE_TYPE: A dictionary with field typed and their coresponding wire types. TYPE_TO_DESERIALIZE_METHOD: A dictionary with field types and deserialization function. s#[email protected] (Will Robinson)i����N(tapi_implementation(tdecoder(tencoder(t wire_format(t descriptorcCs|jjdkS(Ntproto3(tcontaining_typetsyntax(tfield_descriptor((sJ/usr/lib/python2.7/site-packages/google/protobuf/internal/type_checkers.pytSupportsOpenEnums>scCso|jtjkr+|jtjkr+t�S|jtjkrdt|�rTttj St |j �Snt|jS(s Returns a type checker for a message field of the specified types. Args: field: FieldDescriptor object for this field. Returns: An instance of TypeChecker which can be used to verify the types of values assigned to a field of the specified type. ( tcpp_typet_FieldDescriptortCPPTYPE_STRINGttypet TYPE_STRINGtUnicodeValueCheckert CPPTYPE_ENUMR t_VALUE_CHECKERSt CPPTYPE_INT32tEnumValueCheckert enum_type(tfield((sJ/usr/lib/python2.7/site-packages/google/protobuf/internal/type_checkers.pytGetTypeCheckerAs   t TypeCheckercBs eZdZd�Zd�ZRS(sType checker used to catch type errors as early as possible when the client is setting scalar fields in protocol messages. cGs ||_dS(N(t_acceptable_types(tselftacceptable_types((sJ/usr/lib/python2.7/site-packages/google/protobuf/internal/type_checkers.pyt__init__bscCsAt||j�s=d|t|�|jf}t|��n|S(suType check the provided value and return it. The returned value might have been normalized to another type. s,%.1024r has type %s, but expected one of: %s(t isinstanceRR t TypeError(Rtproposed_valuetmessage((sJ/usr/lib/python2.7/site-packages/google/protobuf/internal/type_checkers.pyt CheckValuees (t__name__t __module__t__doc__RR (((sJ/usr/lib/python2.7/site-packages/google/protobuf/internal/type_checkers.pyR\s tTypeCheckerWithDefaultcBseZd�Zd�ZRS(cGstj||�||_dS(N(RRt_default_value(Rt default_valueR((sJ/usr/lib/python2.7/site-packages/google/protobuf/internal/type_checkers.pyRsscCs|jS(N(R%(R((sJ/usr/lib/python2.7/site-packages/google/protobuf/internal/type_checkers.pyt DefaultValuews(R!R"RR'(((sJ/usr/lib/python2.7/site-packages/google/protobuf/internal/type_checkers.pyR$qs tIntValueCheckercBs eZdZd�Zd�ZRS(sFChecker used for integer fields. Performs type-check and range check.cCs�t|tj�s=d|t|�tjf}t|��n|jt|�ko`|j knsxt d|��n|j |�}|S(Ns,%.1024r has type %s, but expected one of: %ssValue out of range: %d( RtnumberstIntegralR tsixt integer_typesRt_MINtintt_MAXt ValueErrort_TYPE(RRR((sJ/usr/lib/python2.7/site-packages/google/protobuf/internal/type_checkers.pyR �s(cCsdS(Ni((R((sJ/usr/lib/python2.7/site-packages/google/protobuf/internal/type_checkers.pyR'�s(R!R"R#R R'(((sJ/usr/lib/python2.7/site-packages/google/protobuf/internal/type_checkers.pyR(}s RcBs)eZdZd�Zd�Zd�ZRS(sCChecker used for enum fields. Performs type-check and range check.cCs ||_dS(N(t _enum_type(RR((sJ/usr/lib/python2.7/site-packages/google/protobuf/internal/type_checkers.pyR�scCslt|tj�s=d|t|�tjf}t|��nt|�|jj krht d|��n|S(Ns,%.1024r has type %s, but expected one of: %ssUnknown enum value: %d( RR)R*R R+R,RR.R2tvalues_by_numberR0(RRR((sJ/usr/lib/python2.7/site-packages/google/protobuf/internal/type_checkers.pyR �scCs|jjdjS(Ni(R2tvaluestnumber(R((sJ/usr/lib/python2.7/site-packages/google/protobuf/internal/type_checkers.pyR'�s(R!R"R#RR R'(((sJ/usr/lib/python2.7/site-packages/google/protobuf/internal/type_checkers.pyR�s  RcBs eZdZd�Zd�ZRS(sgChecker used for string fields. Always returns a unicode value, even if the input is of type str. cCs�t|ttjf�sId|t|�ttjff}t|��nt|t�r�y|jd�}Wq�tk r�td|��q�Xn|S(Ns,%.1024r has type %s, but expected one of: %ssutf-8s�%.1024r has type bytes, but isn't valid UTF-8 encoding. Non-UTF-8 strings must be converted to unicode objects before being added.( RtbytesR+t text_typeR RtdecodetUnicodeDecodeErrorR0(RRR((sJ/usr/lib/python2.7/site-packages/google/protobuf/internal/type_checkers.pyR �s cCsdS(Nu((R((sJ/usr/lib/python2.7/site-packages/google/protobuf/internal/type_checkers.pyR'�s(R!R"R#R R'(((sJ/usr/lib/python2.7/site-packages/google/protobuf/internal/type_checkers.pyR�s tInt32ValueCheckercBseZdZdZeZRS(i�i���(R!R"R-R/R.R1(((sJ/usr/lib/python2.7/site-packages/google/protobuf/internal/type_checkers.pyR:�stUint32ValueCheckercBseZdZdZeZRS(iii ll��(R!R"R-R/R.R1(((sJ/usr/lib/python2.7/site-packages/google/protobuf/internal/type_checkers.pyR;�stInt64ValueCheckercBseZdZdZeZRS(ii?ll����ll����(R!R"R-R/tlongR1(((sJ/usr/lib/python2.7/site-packages/google/protobuf/internal/type_checkers.pyR<�stUint64ValueCheckercBseZdZdZeZRS(iii@ll����(R!R"R-R/R=R1(((sJ/usr/lib/python2.7/site-packages/google/protobuf/internal/type_checkers.pyR>�sgt(�R#t __author__R)R+tPY3R.R=tgoogle.protobuf.internalRRRRtgoogle.protobufRtFieldDescriptorR R RtobjectRR$R(RRR:R;R<R>Rt CPPTYPE_INT64tCPPTYPE_UINT32tCPPTYPE_UINT64tRealtCPPTYPE_DOUBLEt CPPTYPE_FLOATtFalsetboolR*t CPPTYPE_BOOLR6R RtDoubleByteSizet TYPE_DOUBLEt FloatByteSizet TYPE_FLOATt Int64ByteSizet TYPE_INT64tUInt64ByteSizet TYPE_UINT64t Int32ByteSizet TYPE_INT32tFixed64ByteSizet TYPE_FIXED64tFixed32ByteSizet TYPE_FIXED32t BoolByteSizet TYPE_BOOLtStringByteSizeRt GroupByteSizet TYPE_GROUPtMessageByteSizet TYPE_MESSAGEt BytesByteSizet TYPE_BYTEStUInt32ByteSizet TYPE_UINT32t EnumByteSizet TYPE_ENUMtSFixed32ByteSizet TYPE_SFIXED32tSFixed64ByteSizet TYPE_SFIXED64tSInt32ByteSizet TYPE_SINT32tSInt64ByteSizet TYPE_SINT64tTYPE_TO_BYTE_SIZE_FNt DoubleEncodert FloatEncodert Int64Encodert UInt64Encodert Int32EncodertFixed64EncodertFixed32Encodert BoolEncodert StringEncodert GroupEncodertMessageEncodert BytesEncodert UInt32Encodert EnumEncodertSFixed32EncodertSFixed64Encodert SInt32Encodert SInt64EncodertTYPE_TO_ENCODERt DoubleSizert FloatSizert Int64Sizert UInt64Sizert Int32Sizert Fixed64Sizert Fixed32Sizert BoolSizert StringSizert GroupSizert MessageSizert BytesSizert UInt32Sizert EnumSizert SFixed32Sizert SFixed64Sizert SInt32Sizert SInt64Sizert TYPE_TO_SIZERt DoubleDecodert FloatDecodert Int64Decodert UInt64Decodert Int32DecodertFixed64DecodertFixed32Decodert BoolDecodert StringDecodert GroupDecodertMessageDecodert BytesDecodert UInt32Decodert EnumDecodertSFixed32DecodertSFixed64Decodert SInt32Decodert SInt64DecodertTYPE_TO_DECODERtWIRETYPE_FIXED64tWIRETYPE_FIXED32tWIRETYPE_VARINTtWIRETYPE_LENGTH_DELIMITEDtWIRETYPE_START_GROUPtFIELD_TYPE_TO_WIRE_TYPE(((sJ/usr/lib/python2.7/site-packages/google/protobuf/internal/type_checkers.pyt,s