7ec@sdZddlZddlZddlZddlmZyddlmZWne k rgdZnXdgZ ej ej BejBZdZe\ZZZdZddZied 6ed 6ed 6Zejd eZid d6dd6dd6dd6dd6dd6dd6dd6ZdZdZdeeejdZepSeZejd eZd!Z eje d"Z!eje d#Z"de#fd$YZ$dS(%sImplementation of JSONDecoder iN(tscanner(t scanstringt JSONDecodercCs8tjdd\}tjdd\}||| fS(Ns>dss(tstructtunpack(tnantinf((s$/usr/lib64/python2.7/json/decoder.pyt_floatconstantsscCsU|jdd|d}|dkr2|d}n||jdd|}||fS(Ns ii(tcounttrindex(tdoctpostlinenotcolno((s$/usr/lib64/python2.7/json/decoder.pytlinecols   c Cswt||\}}|dkr=d}|j||||St||\}}d}|j|||||||S(Ns#{0}: line {1} column {2} (char {3})s?{0}: line {1} column {2} - line {3} column {4} (char {5} - {6})(RtNonetformat( tmsgR R tendR R tfmtt endlinenotendcolno((s$/usr/lib64/python2.7/json/decoder.pyterrmsg"s s -InfinitytInfinitytNaNs(.*?)(["\\\x00-\x1f])u"t"u\s\u/t/utbu tfu tnu tru ttsutf-8cCs||d|d!}t|dkr_|ddkr_yt|dSWq_tk r[q_Xnd}tt|||dS(NiiitxXisInvalid \uXXXX escape(tlentintt ValueErrorR(tsR tescR((s$/usr/lib64/python2.7/json/decoder.pyt _decode_uXXXX?s" cCs|dkrt}ng}|j}|d}xO|||} | dkrgttd||n| j}| j\} } | rt| tst| |} n|| n| dkrPnL| dkr|rdj | } tt| ||q|| q1ny||} Wn)t k rNttd||nX| dkry|| }Wn9t k rdt | } tt| ||nX|d7}nt ||}|d7}tjd krfd |kod knrf|||d !d krft ||d}d|ko7dknrfd|d d>|dB}|d7}qfnt|}||q1Wdj||fS(sScan the string s for a JSON string. End is the index of the character in s after the quote that started the JSON string. Unescapes all valid JSON string escape sequences and raises ValueError on attempt to decode an invalid string. If strict is False then literal control characters are allowed in the string. Returns a tuple of the decoded string and the index of the character in s after the end quote.isUnterminated string starting atRs\s"Invalid control character {0!r} attusInvalid \escape: iiiiis\uiiii iuN(RtDEFAULT_ENCODINGtappendR#RRtgroupst isinstancetunicodeRt IndexErrortKeyErrortreprR&tsyst maxunicodetunichrtjoin(R$Rtencodingtstrictt_bt_mtchunkst_appendtbegintchunktcontentt terminatorRR%tchartunituni2((s$/usr/lib64/python2.7/json/decoder.pyt py_scanstringIs^               3 s [ \t\n\r]*s cCs|\}} g} | j} || | d!} | dkr| |krm||| j} || | d!} n| dkr|dk r|| } | | dfSi} |dk r|| } n| | dfS| dkrttd|| qn| d7} xtrt|| ||\}} || | d!dkr||| j} || | d!dkrttd|| qn| d7} yM|| |kr| d7} || |kr||| dj} qnWntk rnXy||| \}} Wn)tk r6ttd|| nX| ||fy@|| } | |kr||| dj} || } nWntk rd} nX| d7} | dkrPn+| d krttd || dnyc|| } | |krH| d7} || } | |krH||| dj} || } qHnWntk rbd} nX| d7} | dkrttd|| dqqW|dk r|| } | | fSt | } |dk r|| } n| | fS( NiRt}s1Expecting property name enclosed in double quotest:sExpecting ':' delimitersExpecting objecttt,sExpecting ',' delimiter( R)RRR#RtTrueRR-t StopIterationtdict(t s_and_endR4R5t scan_oncet object_hooktobject_pairs_hookt_wt_wsR$Rtpairst pairs_appendtnextchartresulttkeytvalue((s$/usr/lib64/python2.7/json/decoder.pyt JSONObjects             #                       c Cs|\}}g}|||d!}||kr\|||dj}|||d!}n|dkrv||dfS|j}xEtry|||\} }Wn)tk rttd||nX|| |||d!}||kr!|||dj}|||d!}n|d7}|dkr;Pn'|dkrbttd||nyM|||kr|d7}|||kr|||dj}qnWqtk rqXqW||fS(Nit]sExpecting objectREsExpecting ',' delimiter(RR)RFRGR#RR-( RIRJRMRNR$RtvaluesRQR9RT((s$/usr/lib64/python2.7/json/decoder.pyt JSONArrays@            # cBsGeZdZdddddeddZejdZddZ RS(sSimple JSON decoder Performs the following translations in decoding by default: +---------------+-------------------+ | JSON | Python | +===============+===================+ | object | dict | +---------------+-------------------+ | array | list | +---------------+-------------------+ | string | unicode | +---------------+-------------------+ | number (int) | int, long | +---------------+-------------------+ | number (real) | float | +---------------+-------------------+ | true | True | +---------------+-------------------+ | false | False | +---------------+-------------------+ | null | None | +---------------+-------------------+ It also understands ``NaN``, ``Infinity``, and ``-Infinity`` as their corresponding ``float`` values, which is outside the JSON spec. cCs||_||_||_|p$t|_|p3t|_|pEtj|_ ||_ t |_ t |_t|_tj||_dS(s``encoding`` determines the encoding used to interpret any ``str`` objects decoded by this instance (utf-8 by default). It has no effect when decoding ``unicode`` objects. Note that currently only encodings that are a superset of ASCII work, strings of other encodings should be passed in as ``unicode``. ``object_hook``, if specified, will be called with the result of every JSON object decoded and its return value will be used in place of the given ``dict``. This can be used to provide custom deserializations (e.g. to support JSON-RPC class hinting). ``object_pairs_hook``, if specified will be called with the result of every JSON object decoded with an ordered list of pairs. The return value of ``object_pairs_hook`` will be used instead of the ``dict``. This feature can be used to implement custom decoders that rely on the order that the key and value pairs are decoded (for example, collections.OrderedDict will remember the order of insertion). If ``object_hook`` is also defined, the ``object_pairs_hook`` takes priority. ``parse_float``, if specified, will be called with the string of every JSON float to be decoded. By default this is equivalent to float(num_str). This can be used to use another datatype or parser for JSON floats (e.g. decimal.Decimal). ``parse_int``, if specified, will be called with the string of every JSON int to be decoded. By default this is equivalent to int(num_str). This can be used to use another datatype or parser for JSON integers (e.g. float). ``parse_constant``, if specified, will be called with one of the following strings: -Infinity, Infinity, NaN. This can be used to raise an exception if invalid JSON numbers are encountered. If ``strict`` is false (true is the default), then control characters will be allowed inside strings. Control characters in this context are those with character codes in the 0-31 range, including ``'\t'`` (tab), ``'\n'``, ``'\r'`` and ``'\0'``. N(R4RKRLtfloatt parse_floatR"t parse_intt _CONSTANTSt __getitem__tparse_constantR5RUt parse_objectRXt parse_arrayRt parse_stringRt make_scannerRJ(tselfR4RKRZR[R^R5RL((s$/usr/lib64/python2.7/json/decoder.pyt__init__.s-       cCsy|j|d||dj\}}|||j}|t|kruttd||t|n|S(szReturn the Python representation of ``s`` (a ``str`` or ``unicode`` instance containing a JSON document) tidxis Extra data(t raw_decodeRR!R#R(RcR$RMtobjR((s$/usr/lib64/python2.7/json/decoder.pytdecodegs *$icCsFy|j||\}}Wntk r;tdnX||fS(sLDecode a JSON document from ``s`` (a ``str`` or ``unicode`` beginning with a JSON document) and return a 2-tuple of the Python representation and the index in ``s`` where the document ended. This can be used to decode a JSON document from a string that may have extraneous data at the end. sNo JSON object could be decoded(RJRGR#(RcR$ReRgR((s$/usr/lib64/python2.7/json/decoder.pyRfrs  N( t__name__t __module__t__doc__RRFRdt WHITESPACEtmatchRhRf(((s$/usr/lib64/python2.7/json/decoder.pyRs    7 (%RktreR0RtjsonRt_jsonRt c_scanstringt ImportErrorRt__all__tVERBOSEt MULTILINEtDOTALLtFLAGSRRtPosInftNegInfRRR\tcompilet STRINGCHUNKt BACKSLASHR(R&RFRmRARltWHITESPACE_STRRURXtobjectR(((s$/usr/lib64/python2.7/json/decoder.pyts@         & E W$