Plan 9 from Bell Labs’s /usr/web/sources/contrib/jas/root/sys/lib/python2.7/json/decoder.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


��Qc@s�dZddlZddlZddlZddlmZyddlmZWne	k
rgdZnXdgZejej
BejBZd�Ze�\ZZZd�Zdd�Zied	6ed
6ed6Zejde�Zid
d6dd6dd6dd6dd6dd6dd6dd6ZdZdeeejd�ZepJeZejde�Zd Zejed!�Z ejed"�Z!de"fd#��YZ#dS($sImplementation of JSONDecoder
i�N(tscanner(t
scanstringtJSONDecodercCssdjd�}tjdkrM|d ddd�|dddd�}ntjd|�\}}|||fS(Nt 7FF80000000000007FF0000000000000thextbigii�tdd(tdecodetsyst	byteordertstructtunpack(t_BYTEStnantinf((s"/sys/lib/python2.7/json/decoder.pyt_floatconstantss
/cCsU|jdd|�d}|dkr2|d}n||jdd|�}||fS(Ns
ii(tcounttrindex(tdoctpostlinenotcolno((s"/sys/lib/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(	tmsgRRtendRRtfmtt	endlinenotendcolno((s"/sys/lib/python2.7/json/decoder.pyterrmsg$ss	-InfinitytInfinitytNaNs(.*?)(["\\\x00-\x1f])u"t"u\s\u/t/utbutfu
tnu
tru	ttsutf-8cCs$|dkrt}ng}|j}|d}x�||�}	|	dkrgttd||���n|	j�}|	j�\}
}|
r�t|
t�s�t|
|�}
n||
�n|dkr�PnL|dkr|rdj	|�}tt|||���q||�q1ny||}
Wn)t
k
rNttd||���nX|
dkr�y||
}Wn9tk
r�dt|
�}tt|||���nX|d7}nR||d|d!}
|d}t
|
�d	krd
}tt|||���nt|
d�}d|ko*d
knr�jdkr�}||d|d!dksztt|||���n||d|d!}t
|�d	kr�tt|||���nt|d�}d|dd>|dB}|d7}nt|�}|}||�q1dj|�|fS(s�Scan 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 atR!s\s"Invalid control character {0!r} attusInvalid \escape: iisInvalid \uXXXX escapeii�i�i�s#Invalid \uXXXX\uXXXX surrogate pairis\uiii
i�iuN(RtDEFAULT_ENCODINGtappendt
ValueErrorRRtgroupst
isinstancetunicodeRt
IndexErrortKeyErrortreprtlentintRt
maxunicodetunichrtjoin(tsRtencodingtstrictt_bt_mtchunkst_appendtbegintchunktcontentt
terminatorRtesctchartnext_endtunitesc2tuni2((s"/sys/lib/python2.7/json/decoder.pyt
py_scanstringAsp
		






+

s
[ \t\n\r]*s 	

cCs�|\}}	g}
|
j}||	|	d!}|dkr�|krm|||	�j�}	||	|	d!}n|dkr�|dk	r�||
�}
|
|	dfSi}
|dk	r�||
�}
n|
|	dfS|dkr�td||	���q�|	d7}	x�tr�t||	||�\}}	||	|	d!dkr�|||	�j�}	||	|	d!dkr�ttd||	���q�n|	d7}	yM||	|kr�|	d7}	||	|kr�|||	d�j�}	q�nWntk
r�nXy|||	�\}}	Wn)tk
r6ttd||	���nX|||f�y@||	}||kr�|||	d�j�}	||	}nWntk
r�d}nX|	d7}	|dkr�Pn+|d	kr�td
||	d���nyc||	}||krH|	d7}	||	}||krH|||	d�j�}	||	}qHnWntk
rbd}nX|	d7}	|dkrttd||	d���qqW|dk	r�||
�}
|
|	fSt	|
�}
|dk	r�|
�}
n|
|	fS(NiR!t}s1Expecting property name enclosed in double quotest:sExpecting ':' delimitersExpecting objecttt,sExpecting ',' delimiter(
R*RRR+RtTrueRR/t
StopIterationtdict(t	s_and_endR8R9t	scan_oncetobject_hooktobject_pairs_hookt_wt_wsR7Rtpairstpairs_appendtnextchartresulttkeytvalue((s"/sys/lib/python2.7/json/decoder.pyt
JSONObject�s�	
	

#












c
Cs�|\}}g}|||d!}||kr\|||d�j�}|||d!}n|dkrv||dfS|j}xEtr�y|||�\}	}Wn)tk
r�ttd||���nX||	�|||d!}||kr!|||d�j�}|||d!}n|d7}|dkr;Pn'|dkrbttd||���nyM|||kr�|d7}|||kr�|||d�j�}q�nWq�tk
r�q�Xq�W||fS(Nit]sExpecting objectRLsExpecting ',' delimiter(RR*RMRNR+RR/(
RPRQRTRUR7RtvaluesRXR=R[((s"/sys/lib/python2.7/json/decoder.pyt	JSONArray�s@		



#
cBsGeZdZdddddedd�Zejd�Zdd�Z	RS(sSimple JSON <http://json.org> 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(R8RRRStfloattparse_floatR3t	parse_intt
_CONSTANTSt__getitem__tparse_constantR9R\tparse_objectR_tparse_arrayRtparse_stringRtmake_scannerRQ(tselfR8RRRaRbReR9RS((s"/sys/lib/python2.7/json/decoder.pyt__init__/s-							cCsy|j|d||d�j��\}}|||�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_decodeRR2R+R(RjR7RTtobjR((s"/sys/lib/python2.7/json/decoder.pyRhs
*$icCsFy|j||�\}}Wntk
r;td��nX||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(RQRNR+(RjR7RlRnR((s"/sys/lib/python2.7/json/decoder.pyRmss
	
N(
t__name__t
__module__t__doc__RRMRkt
WHITESPACEtmatchRRm(((s"/sys/lib/python2.7/json/decoder.pyRs		7($RqtreRR
tjsonRt_jsonRtc_scanstringtImportErrorRt__all__tVERBOSEt	MULTILINEtDOTALLtFLAGSRR tPosInftNegInfRRRctcompiletSTRINGCHUNKt	BACKSLASHR)RMRsRHRrtWHITESPACE_STRR\R_tobjectR(((s"/sys/lib/python2.7/json/decoder.pyt<module>s>

				
&NW$

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].