B VXY8 @sRdZddlmZddlZddlZddlZddlmZmZm Z m Z m Z ddl m Z mZddZeZd gZejejBejBZd d Ze\ZZZeeed Zed eZededededededededdZdZddeejedj e ej!fddZ"ep e"Z#edeZ$dZ%de$je%fddZ&e$je%fd d!Z'Gd"d d e(Z)dS)#zImplementation of JSONDecoder )absolute_importN)u text_type binary_typePY3unichr) make_scannerJSONDecodeErrorcCs*yddlm}|Stk r$dSXdS)Nr) scanstring)Z _speedupsr ImportError)r r E/opt/alt/python37/lib64/python3.7/site-packages/simplejson/decoder.py_import_c_scanstring s  r JSONDecodercCsBtjdkr&dd}td|\}}ntd}td}||| fS)N)Z 7FF80000000000007FF0000000000000hexz>ddnaninf)sys version_infodecodestructunpackfloat)Z_BYTESrrr r r_floatconstantss   r)z -InfinityInfinityNaNz(.*?)(["\\\x00-\x1f])"\/    )rr r!bfnrtzutf-8Tc Cs|dkr t}g} | j} |d} xz|||} | dkr@td|| | }| \} }| rx|spt| tspt| |} | | |dkrPn(|dkr|rd}t|||n | |q"y ||}Wn tk rtd|| YnX|dkr$y ||}Wn&tk rd}t|||YnX|d7}nld }||d|d }|dd }t |d ksj|d ksj|dkrzt|||dyt |d}Wn&t k rt|||dYnX|d 7}|dkr|d@dkr|||d dkr||d |d}|dd }t |d kr|d ks|dksyt |d}Wn"t k rXt|||YnX|d@dkrd|dd>|dB}|d7}t |}| |q"W|| |fS)aScan 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.NrzUnterminated string starting atrr zInvalid control character %r atrzInvalid \X escape sequence %rzInvalid \uXXXX escape sequencerxXiiiz\urii ) DEFAULT_ENCODINGappendr endgroups isinstancer IndexErrorKeyErrorlenint ValueErrorr)sr5encodingstrict_b_mZ_join_PY3Z _maxunicodechunks_appendbeginchunkcontent terminatormsgesccharZescXuniZesc2uni2r r r py_scanstring1s~          "  "   rNz [ \t\n\r]*z c Cs|\} } |dkri}|j} g} | | | d} | dkr| |kr\|| | } | | | d} | dkr|dk r|| }|| dfSi} |dk r|| } | | dfS| dkrtd| | | d7} xt| | ||\}} | ||}| | | ddkr"|| | } | | | ddkr"td| | | d7} y:| | |krb| d7} | | |krb|| | d} Wntk rzYnX|| | \}} | ||fy0| | } | |kr|| | d} | | } Wntk rd} YnX| d7} | dkrPn| dkrtd | | dyJ| | } | |kr\| d7} | | } | |kr\|| | d} | | } Wntk rxd} YnX| d7} | dkrtd| | dqW|dk r|| }|| fSt| } |dk r|| } | | fS) Nrr}z1Expecting property name enclosed in double quotes:zExpecting ':' delimiterr,,zExpecting ',' delimiter or '}') setdefaultr5r r r8r4dict)stater>r? scan_once object_hookobject_pairs_hookmemo_w_wsr=r5memo_getpairsnextcharresultkeyvaluer r r JSONObjects               rac CsP|\}}g}|||d}||krF|||d}|||d}|dkrZ||dfS|dkrntd|||j}x|||\} }|| |||d}||kr|||d}|||d}|d7}|dkrPn|dkrtd||dy:|||kr*|d7}|||kr*|||d}Wqvtk rBYqvXqvW||fS)Nr]r,zExpecting value or ']'rQzExpecting ',' delimiter or ']')r5r r4r8) rTrUrYrZr=r5valuesr]rDr`r r r JSONArrays>   rdc@s<eZdZdZd ddZejefddZdejefd d Z dS) raSimple JSON 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. NTcCsj|dkr t}||_||_||_|p$t|_|p.t|_|p:tj |_ ||_ t |_ t|_t|_i|_t||_dS)a *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)r3r>rVrWr parse_floatr; parse_int _CONSTANTS __getitem__parse_constantr?ra parse_objectrd parse_arrayr parse_stringrXr rU)selfr>rVrerfrir?rWr r r__init__.s.   zJSONDecoder.__init__cCsX|rt|tr||j}||\}}|||}|t|krTtd||t||S)zzReturn the Python representation of ``s`` (a ``str`` or ``unicode`` instance containing a JSON document) z Extra data)r7rrr> raw_decoder5r:r )rmr=rYrBobjr5r r rrks  zJSONDecoder.decodercCs|dkrtd|||r*t|ts*tdt||krxt||}|dkrT|d7}n$|dkrx|||ddkrx|d7}|j||||d S) aDecode 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. rzExpecting valuez$Input string must be text, not bytesiru)idx)r r7r TypeErrorr:ordrUr5)rmr=rsrYrBZord0r r rroxs     zJSONDecoder.raw_decode)NNNNNTN) __name__ __module__ __qualname____doc__rn WHITESPACEmatchrrror r r rrs  ; )*ry __future__rrerrcompatrrrrrscannerr r r c_scanstring__all__VERBOSE MULTILINEDOTALLFLAGSrrPosInfNegInfrgcompile STRINGCHUNK BACKSLASHr3r{join maxunicoderNr rzWHITESPACE_STRrardobjectrr r r rs:   $V  \$