� S�Ljc@s�dZdZyddlmZWn!ek rCddlmZnXddlZddlZddlZddl Z ddl Z ddl Z ddl m Z ddlmZddlmZdZeejjejjejjejjg�Zeejjejjg�Zeejjejjg�Zd Zd Zd Ze j e j!d ��Z"e j d �Z#de$fd��YZ%de%fd��YZ&de%fd��YZ'e(e(de(d�Z)e(e(d�Z*d�Z+de,fd��YZ-d�Z.d�Z/d�Z0e(d�Z1e(d�Z2e j3e4fZ5de,fd ��YZ6e(d!�Z7d"�Z8d#�Z9d$�Z:id%d&gd'6d(d)gd*6d(d)gd+6d,d-gd.6d/d0gd16d(d)gd26d3d4gd56Z;dS(6stContains routines for printing protocol messages in JSON format. Simple usage example: # Create a proto object and serialize it to a json format string. message = my_proto_pb2.MyMessage(foo='bar') json_string = json_format.MessageToJson(message) # Parse a json format string to proto object. message = json_format.Parse(json_string, my_proto_pb2.MyMessage()) smail protected] (Jie Luo)i����(t OrderedDictN(t methodcaller(t descriptor(tsymbol_databases%Y-%m-%dT%H:%M:%StInfinitys -InfinitytNaNsF[\ud800-\udbff](?![\udc00-\udfff])|(?Rt CPPTYPE_ENUMt enum_typetvalues_by_numbertgettNoneR0tfiletsyntaxR tCPPTYPE_STRINGRt TYPE_BYTEStbase64t b64encodetdecodet CPPTYPE_BOOLR4t _INT64_TYPEStstrt _FLOAT_TYPEStmathtisinft _NEG_INFINITYt _INFINITYtisnant_NAN(R RR,t enum_value((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyR5�s2     cCs�|j�siSt�}|j}||dConverts Value message according to Proto3 JSON Specification.tkindt null_valuet list_valuet struct_valueN( t WhichOneofROt_ListValueMessageToJsonObjectRjRktgetattrR%R2R5(R RtwhichR,toneof_descriptor((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyt_ValueMessageToJsonObject1s   cCs#g|jD]}|j|�^q S(sBConverts ListValue message according to Proto3 JSON Specification.(tvaluesRq(R RR,((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyRmAscCs;|j}i}x%|D]}|j||�||�ss)Message type {0} does not have extensionsii����t.sVMessage type "{0}" has no field named "{1}". Available Fields(except extensions): {2}s9Message type "{0}" should not have multiple "{1}" fields.s?Message type "{0}" should not have multiple "{1}" oneof fields.sgoogle.protobuf.Valueis.repeated field {0} must be in [] which is {1}.sAnull is not allowed to be used as an element in a repeated field.sFailed to parse {0} field: {1}sFailed to parse {0} field: {1}.N(+R%tdictR<RNROR2t_VALID_EXTENSION_NAMEtmatcht is_extendableR RBR&tjoinRzt Extensionst_FindExtensionByNameR�tappendR?R0R=RRR>RRnRit ClearFieldRt_ConvertMapFieldValueR6R7R3tlisttaddR�t_ConvertScalarFieldValueR8t SetInParenttsetattrRYRAR~(R R$RtnamesR+tfields_by_json_nameR0Rt identifiert oneof_nameR,RetitemRI((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyR��s�                           cCs�t|t�r| rdSy|d}Wntk rGtd��nXt|�}|j}|j}t|�r�|j|d|�nH|t kr�t t |d|d|�|�n|d=|j ||�|j �|_ ||_dS(s/Convert a JSON representation into Any message.Ns@types*@type is missing when parsing any message.R,i(R3R�R}R RcR%R&R'R�R)RR�tSerializeToStringR,Rb(R R,RRbReR+R&((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyt_ConvertAnyMessages$      "cCs|j|�dS(s?Convert a JSON representation into message with FromJsonString.N(tFromJsonString(R R,R((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyt_ConvertGenericMessage7scCs�t|t�r%|j||j�n�t|t�rJ|j||j�nx|dkrbd|_n`t|t �r}||_ nEt|t j �r�||_ n't|t�r�||_n td��dS(s1Convert a JSON representation into Value message.is"Unexpected type for Value message.N(R3R�t_ConvertStructMessageRkR�t_ConvertListValueMessageRjRORiR4t bool_valueR�t string_typest string_valuet _INT_OR_FLOATt number_valueR (R R,R((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyt_ConvertValueMessage=s     cCsbt|t�s'tdj|���n|jd�x'|D]}|j||jj��q;WdS(s5Convert a JSON representation into ListValue message.s%ListValue must be in [] which is {0}.RrN(R3R�R RBR�R�RrR�(R R,RR�((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyR�Ns   cCsWt|t�s'tdj|���nx)|D]!}|j|||j|�q.WdS(s2Convert a JSON representation into Struct message.s&Struct must be in a dict which is {0}.N(R3R�R RBR�R<(R R,RRE((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyR�Ws  cCs-|jjd}t|dt||��dS(s3Convert a JSON representation into Wrapper message.R,N(R%R2R�R�(R R,RR((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyR�`scCs�t|t�s-tdj|j|���n|jjd}|jjd}x|D]w}t||t�}|j t j j kr�|j ||t||j�|�qTt|||�t||j�|R�Rn(R R,RRt key_fieldt value_fieldREt key_value((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyR�es  ( RRR R!R�R�R�R�R�R�R�R�R�(((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyR��s   j    cCs�|jtkrt|�S|jtkr2t|�S|jtjjkrTt||�S|jtjj kr�|j tjj kr�t j |�Stj|�r�td��n|Sn�|jtjjkr�|jjj|d�}|dkr�y(t|�}|jjj|d�}Wn/tk rBtdj||jj���nX|dkr�|jjdkre|Stdj||jj���q�n|jSdS(sBConvert a single scalar field value. Args: value: A scalar value to convert the scalar field value. field: The descriptor of the field to convert. require_str: If True, the field value must be a str. Returns: The converted scalar field value Raises: ParseError: In case of convert problems. sUnpaired surrogates)Invalid enum value {0} for enum type {1}.RJN(R=t _INT_TYPESt_ConvertIntegerRZt _ConvertFloatRRRWt _ConvertBoolRRRRSRTt b64decodet_UNPAIRED_SURROGATE_PATTERNtsearchR RKRLtvalues_by_nameRNROtintRMRARBR&RPRQtnumber(R,Rt require_strRaR�((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyR��s6          cCs}t|t�r4|j� r4tdj|���nt|tj�rs|jd�dkrstdj|���nt|�S(s�Convert an integer. Args: value: A scalar value to convert. Returns: The integer value. Raises: ParseError: If an integer couldn't be consumed. sCouldn't parse integer: {0}.t i����sCouldn't parse integer: "{0}".( R3tfloatt is_integerR RBR�R�tfindR�(R,((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyR��s 'cCs�|dkrtd��nyt|�SWnhtk r�|tkrOtd�S|tkretd�S|tkr{td�Stdj|���nXdS(s!Convert an floating point number.tnans.Couldn't parse float "nan", use "NaN" instead.s-inftinfsCouldn't parse float: {0}.N(R R�RAR]R^R`RB(R,((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyR��s        cCs`|r>|dkrtS|dkr&tStdj|���nt|t�s\td��n|S(s�Convert a boolean value. Args: value: A scalar value to convert. require_str: If True, value must be a str. Returns: The bool parsed. Raises: ParseError: If a boolean value couldn't be consumed. R-R.s$Expected "true" or "false", not {0}.s&Expected true or false without quotes.(R�RuR RBR3R4(R,R�((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyR��s   RfR�sgoogle.protobuf.AnyRgR�sgoogle.protobuf.Durationsgoogle.protobuf.FieldMaskRmR�sgoogle.protobuf.ListValueRtR�sgoogle.protobuf.Structsgoogle.protobuf.TimestampRqR�sgoogle.protobuf.Value(<R t __author__t collectionsRt ImportErrort ordereddictRTR"R[treR�R�toperatorRtgoogle.protobufRRt_TIMESTAMPFOMATt frozensetRt CPPTYPE_INT32tCPPTYPE_UINT32t CPPTYPE_INT64tCPPTYPE_UINT64R�RXt CPPTYPE_FLOATtCPPTYPE_DOUBLERZR^R]R`tcompiletuR�R�t ExceptionRR R RuRRRtobjectR R'RwRcR�R�t integer_typesR�R�R�R�R�R�R�R)(((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyt)s�                 �    � 0