Your IP : 18.188.39.173


Current Path : /lib64/python2.7/site-packages/simplejson/
Upload File :
Current File : //lib64/python2.7/site-packages/simplejson/decoder.pyc

�
MHYc@@s�dZddlmZddlZddlZddlZddlmZmZm	Z	m
Z
mZddlm
Z
mZd�Ze�ZdgZejejBejBZd	�Ze�\ZZZied
6ed6ed6Zejd
e�Zied�d6ed�d6ed�d6ed�d6ed�d6ed�d6ed�d6ed�d6ZdZde eej!ed�j"e
ej#d�Z$ep�e$Z%ejde�Z&d Z'de&j!e'd!�Z(e&j!e'd"�Z)de*fd#��YZ+dS($sImplementation of JSONDecoder
i(tabsolute_importNi(tut	text_typetbinary_typetPY3tunichr(tmake_scannertJSONDecodeErrorcC@s1yddlm}|SWntk
r,dSXdS(Ni(t
scanstring(t	_speedupsRtImportErrortNone(R((s8/usr/lib64/python2.7/site-packages/simplejson/decoder.pyt_import_c_scanstring
s

tJSONDecodercC@s_tjdkr9djd�}tjd|�\}}ntd�}td�}|||fS(	Niit 7FF80000000000007FF0000000000000thexs>ddtnantinf(ii(tsystversion_infotdecodetstructtunpacktfloat(t_BYTESRR((s8/usr/lib64/python2.7/site-packages/simplejson/decoder.pyt_floatconstantsss	-InfinitytInfinitytNaNs(.*?)(["\\\x00-\x1f])t"s\u005cs\t/stbstfs
tns
trs	ttsutf-8tc	C@s`|dkrt}ng}	|	j}
|d}x|||�}|dkratd||��n|j�}|j�\}
}|
r�|r�t|
t�r�t|
|�}
n|
|
�n|dkr�Pn=|dkr|r�d}t|||��q|
|�q1ny||}Wn#tk
r;td||��nX|dkr�y||}Wn)t	k
r�d}t|||��nX|d7}n�d}||d|d	!}|dd
!}t
|�dks�|dks�|d
kr�t|||d��nyt|d�}Wn'tk
r6t|||d��nX|d	7}|dkr7|d@dkr7|||d
!dkr7||d
|d!}|dd
!}t
|�dkr7|dkp�|d
kr7yt|d�}Wn#tk
r�t|||��nX|d@dkr4d|dd>|dB}|d7}q4q7nt
|�}|
|�q1||	�|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 atRs\sInvalid control character %r atRsInvalid \X escape sequence %rsInvalid \uXXXX escape sequenceiiitxtXii��i�i�s\uii�ii
N(RtDEFAULT_ENCODINGtappendRtendtgroupst
isinstanceRt
IndexErrortKeyErrortlentintt
ValueErrorR(tsR(tencodingtstrictt_bt_mt_joint_PY3t_maxunicodetchunkst_appendtbegintchunktcontentt
terminatortmsgtesctchartescXtunitesc2tuni2((s8/usr/lib64/python2.7/site-packages/simplejson/decoder.pyt
py_scanstring1s~		






*

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

c	C@s�|\}	}
|dkr!i}n|j}g}|	|
|
d!}
|
dkr|
|kr�||	|
�j�}
|	|
|
d!}
n|
dkr�|dk	r�||�}||
dfSi}|dk	r�||�}n||
dfS|
dkrtd|	|
��qn|
d7}
xgtrzt|	|
||�\}}
|||�}|	|
|
d!dkr�||	|
�j�}
|	|
|
d!dkr�td|	|
��q�n|
d7}
yM|	|
|kr�|
d7}
|	|
|kr�||	|
d�j�}
q�nWntk
r	nX||	|
�\}}
|j||f�y@|	|
}
|
|krq||	|
d�j�}
|	|
}
nWntk
r�d}
nX|
d7}
|
dkr�Pn%|
dkr�td	|	|
d��nyc|	|
}
|
|kr-|
d7}
|	|
}
|
|kr-||	|
d�j�}
|	|
}
q-nWntk
rGd}
nX|
d7}
|
dkrtd|	|
d��qqW|dk	r�||�}||
fSt|�}|dk	r�||�}n||
fS(
NiRt}s1Expecting property name enclosed in double quotest:sExpecting ':' delimiterR#t,sExpecting ',' delimiter or '}'(	Rt
setdefaultR(RtTrueRR+R'tdict(tstateR1R2t	scan_oncetobject_hooktobject_pairs_hooktmemot_wt_wsR0R(tmemo_gettpairstnextchartresulttkeytvalue((s8/usr/lib64/python2.7/site-packages/simplejson/decoder.pyt
JSONObject�s�		
	

#











c
C@s�|\}}g}|||d!}||kr\|||d�j�}|||d!}n|dkrv||dfS|dkr�td||��n|j}xtr�|||�\}	}||	�|||d!}||kr|||d�j�}|||d!}n|d7}|dkr,Pn%|dkrQtd||d��nyM|||kr�|d7}|||kr�|||d�j�}q�nWq�tk
r�q�Xq�W||fS(Nit]R#sExpecting value or ']'RHsExpecting ',' delimiter or ']'(R(RR'RJR+(
RLRMRQRRR0R(tvaluesRUR9RX((s8/usr/lib64/python2.7/site-packages/simplejson/decoder.pyt	JSONArray�s>		


#
cB@sSeZdZdddddedd�Zejed�Z	dejed�Z
RS(sSimple JSON <http://json.org> decoder

    Performs the following translations in decoding by default:

    +---------------+-------------------+
    | JSON          | Python            |
    +===============+===================+
    | object        | dict              |
    +---------------+-------------------+
    | array         | list              |
    +---------------+-------------------+
    | string        | str, 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.

    cC@s�|dkrt}n||_||_||_|p9t|_|pHt|_|pZt	j
|_||_t
|_t|_t|_i|_t|�|_dS(s	
        *encoding* determines the encoding used to interpret any
        :class:`str` objects decoded by this instance (``'utf-8'`` by
        default).  It has no effect when decoding :class:`unicode` objects.

        Note that currently only encodings that are a superset of ASCII work,
        strings of other encodings should be passed in as :class:`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 :class:`dict`.  This can be used to provide custom
        deserializations (e.g. to support JSON-RPC class hinting).

        *object_pairs_hook* is an optional function that will be called with
        the result of any object literal decode with an ordered list of pairs.
        The return value of *object_pairs_hook* will be used instead of the
        :class:`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, :func:`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. :class:`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. :class:`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.

        *strict* controls the parser's behavior when it encounters an
        invalid control character in a string. The default setting of
        ``True`` means that unescaped control characters are parse errors, if
        ``False`` then control characters will be allowed in strings.

        N(RR&R1RNRORtparse_floatR.t	parse_intt
_CONSTANTSt__getitem__tparse_constantR2RYtparse_objectR\tparse_arrayRtparse_stringRPRRM(tselfR1RNR]R^RaR2RO((s8/usr/lib64/python2.7/site-packages/simplejson/decoder.pyt__init__.s.									cC@s�|r*t|t�r*|j|j�}n|j|�\}}|||�j�}|t|�kr�td||t|���n|S(szReturn the Python representation of ``s`` (a ``str`` or ``unicode``
        instance containing a JSON document)

        s
Extra data(R*RRR1t
raw_decodeR(R-R(ReR0RQR6tobjR(((s8/usr/lib64/python2.7/site-packages/simplejson/decoder.pyRksicC@s�|dkr!td||��n|rFt|t�rFtd��nt|�|kr�t||�}|dkr�|d7}q�|dkr�|||d!dkr�|d7}q�n|j|d	|||�j��S(
s�Decode 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.
        Optionally, ``idx`` can be used to specify an offset in ``s`` where
        the JSON document begins.

        This can be used to decode a JSON document from a string that may
        have extraneous data at the end.

        isExpecting values$Input string must be text, not bytesi��ii�istidx(RR*Rt	TypeErrorR-tordRMR((ReR0RiRQR6tord0((s8/usr/lib64/python2.7/site-packages/simplejson/decoder.pyRgxs
#N(t__name__t
__module__t__doc__RRJRft
WHITESPACEtmatchRRRg(((s8/usr/lib64/python2.7/site-packages/simplejson/decoder.pyR
s		;
(,Rot
__future__RtreRRtcompatRRRRRtscannerRRRtc_scanstringt__all__tVERBOSEt	MULTILINEtDOTALLtFLAGSRRtPosInftNegInfR_tcompiletSTRINGCHUNKt	BACKSLASHR&RRJRqtjoint
maxunicodeRERRptWHITESPACE_STRRYR\tobjectR
(((s8/usr/lib64/python2.7/site-packages/simplejson/decoder.pyt<module>s>(					
'DV\$