ó Du—ac@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()) sjieluo@google.com (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ƒnt|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 RBRR´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²RR¡RºR»R¼R)(((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyt)s„                 »    å 0