eaiovnaovbqoebvqoeavibavo  Duac@sdZdZyddlmZWn!ek rCddlmZnXddlZddlZddlZddl Z ddl Z ddl Z ddl m Z ddlmZddlmZdZeejjejjejjejjgZeejjejjgZeejjejjgZd Zd Zd Ze j e j!d Z"e j d Z#de$fdYZ%de%fdYZ&de%fdYZ'e(e(de(dZ)e(e(dZ*dZ+de,fdYZ-dZ.dZ/dZ0e(dZ1e(dZ2e 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.pyR5s2     cCs|jsiSt}|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 extensionsiit.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_FindExtensionByNameRtappendR?R0R=RRR>RRnRit ClearFieldRt_ConvertMapFieldValueR6R7R3tlisttaddRt_ConvertScalarFieldValueR8t SetInParenttsetattrRYRAR~(R R$RtnamesR+tfields_by_json_nameR0Rt identifiert oneof_nameR,RetitemRI((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyRs                           cCst|tr| rdSy|d}Wntk rGtdnXt|}|j}|j}t|r|j|d|nH|t krt 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(R3RR}R RcR%R&R'RR)RRtSerializeToStringR,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_ConvertGenericMessage7scCst|tr%|j||jnt|trJ|j||jnx|dkrbd|_n`t|t r}||_ nEt|t j r||_ n't|tr||_n tddS(s1Convert a JSON representation into Value message.is"Unexpected type for Value message.N(R3Rt_ConvertStructMessageRkRt_ConvertListValueMessageRjRORiR4t bool_valueRt 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|ts'tdj|n|jdx'|D]}|j||jjq;WdS(s5Convert a JSON representation into ListValue message.s%ListValue must be in [] which is {0}.RrN(R3RR RBRRRrR(R R,RR((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyRNs   cCsWt|ts'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(R3RR RBRR<(R R,RRE((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyRWs  cCs-|jjd}t|dt||dS(s3Convert a JSON representation into Wrapper message.R,N(R%R2RR(R R,RR((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyR`scCst|ts-tdj|j|n|jjd}|jjd}x|D]w}t||t}|j t j j kr|j ||t||j|qTt|||t||j|RRn(R R,RRt key_fieldt value_fieldREt key_value((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyRes  ( RRR R!RRRRRRRRR(((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyRs   j    cCs|jtkrt|S|jtkr2t|S|jtjjkrTt||S|jtjj kr|j tjj krt j |Stj|rtdn|Sn|jtjjkr|jjj|d}|dkry(t|}|jjj|d}Wn/tk rBtdj||jjnX|dkr|jjdkre|Stdj||jjqn|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.pyRs6          cCs}t|tr4|j r4tdj|nt|tjrs|jddkrstdj|nt|S(sConvert 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 isCouldn't parse integer: "{0}".( R3tfloatt is_integerR RBRRtfindR(R,((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyRs 'cCs|dkrtdnyt|SWnhtk r|tkrOtdS|tkretdS|tkr{tdStdj|nXdS(s!Convert an floating point number.tnans.Couldn't parse float "nan", use "NaN" instead.s-inftinfsCouldn't parse float: {0}.N(R RRAR]R^R`RB(R,((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyRs        cCs`|r>|dkrtS|dkr&tStdj|nt|ts\tdn|S(sConvert 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.(RRuR RBR3R4(R,R((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyRs   RfRsgoogle.protobuf.AnyRgRsgoogle.protobuf.Durationsgoogle.protobuf.FieldMaskRmRsgoogle.protobuf.ListValueRtRsgoogle.protobuf.Structsgoogle.protobuf.TimestampRqRsgoogle.protobuf.Value(<R t __author__t collectionsRt ImportErrort ordereddictRTR"R[treRRtoperatorRtgoogle.protobufRRt_TIMESTAMPFOMATt frozensetRt CPPTYPE_INT32tCPPTYPE_UINT32t CPPTYPE_INT64tCPPTYPE_UINT64RRXt CPPTYPE_FLOATtCPPTYPE_DOUBLERZR^R]R`tcompiletuRRt ExceptionRR R RuRRRtobjectR R'RwRcRRt integer_typesRRRRRRRR)(((s?/usr/lib/python2.7/site-packages/google/protobuf/json_format.pyt)s                      0