B VX�Y�8� @sRdZddlmZddlZddlZddlZddlmZmZm Z m Z m Z ddl m Z mZdd�Ze�Zd gZejejBejBZd d �Ze�\ZZZeeed �Ze�d e�Zed�ed�ed�ed�ed�ed�ed�ed�d�ZdZddeejed�j e ej!fdd�Z"e�p e"Z#e�de�Z$dZ%de$je%fdd�Z&e$je%fd d!�Z'Gd"d �d e(�Z)dS)#zImplementation of JSONDecoder �)�absolute_importN�)�u� text_type� binary_type�PY3�unichr)� make_scanner�JSONDecodeErrorcCs*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&d�d�}t�d|�\}}ntd�}td�}||| fS)N)��Z 7FF80000000000007FF0000000000000�hexz>dd�nan�inf)�sys� version_info�decode�struct�unpack�float)Z_BYTESrrr r r�_floatconstantss   r)z -InfinityZInfinity�NaNz(.*?)(["\\\x00-\x1f])�"�\�/�� � � � )rrr �b�f�n�r�tzutf-8T�c Cs�|dkr t}g} | j} |d} �xz|||�} | dkr@td|| ��| ��}| ��\} }| rx|spt| t�spt| |�} | | �|dkr�Pn(|dkr�|r�d}t|||��n | |�q"y ||}Wn tk r�td|| ��YnX|dk�r$y ||}Wn&tk �rd}t|||��YnX|d7}�nld }||d|d �}|dd �}t |�d k�sj|d k�sj|dk�rzt|||d��yt |d�}Wn&t k �r�t|||d��YnX|d 7}|dk�r�|d@dk�r�|||d �dk�r�||d |d�}|dd �}t |�d k�r�|d k�s�|dk�s�yt |d�}Wn"t k �rXt|||��YnX|d@dk�r�d|dd>|dB}|d7}t |�}| |�q"W|| �|fS)a�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.NrzUnterminated string starting atrrzInvalid control character %r atrzInvalid \X escape sequence %rzInvalid \uXXXX escape sequence�r��x�X�i��i�i�z\uri�i� ) �DEFAULT_ENCODING�appendr �end�groups� isinstancer� IndexError�KeyError�len�int� ValueErrorr)�sr4�encoding�strictZ_b�_mZ_join�_PY3Z _maxunicodeZchunks�_appendZbegin�chunkZcontent� terminator�msgZesc�charZescXZuniZesc2Zuni2r r r� py_scanstring1s~          "  "   rFz [ \t\n\r]*z c Cs�|\} } |dkri}|j} g} | | | d�} | dkr�| |kr\|| | ���} | | | d�} | dkr�|dk r�|| �}|| dfSi} |dk r�|| �} | | dfS| dkr�td| | ��| d7} �x�t| | ||�\}} | ||�}| | | d�dk�r"|| | ���} | | | d�dk�r"td| | ��| d7} y:| | |k�rb| d7} | | |k�rb|| | d���} Wntk �rzYnX|| | �\}} | �||f�y0| | } | |k�r�|| | d���} | | } Wntk �r�d} YnX| d7} | dk�r�Pn| dk�rtd | | d��yJ| | } | |k�r\| d7} | | } | |k�r\|| | d���} | | } Wntk �rxd} YnX| d7} | dkr�td| | d��q�W|dk �r�|| �}|| fSt| �} |dk �r�|| �} | | fS) Nrr�}z1Expecting property name enclosed in double quotes�:zExpecting ':' delimiterr+�,zExpecting ',' delimiter or '}')� setdefaultr4r r r7r3�dict)�stater=r>� scan_once� object_hook�object_pairs_hook�memo�_w�_wsr<r4Zmemo_getZpairs�nextchar�result�key�valuer r r� JSONObject�s�               rWc CsP|\}}g}|||d�}||krF|||d���}|||d�}|dkrZ||dfS|dkrntd||��|j}x�|||�\} }|| �|||d�}||kr�|||d���}|||d�}|d7}|dkr�Pn|dkr�td||d��y:|||k�r*|d7}|||k�r*|||d���}Wqvtk �rBYqvXqvW||fS)Nr�]r+zExpecting value or ']'rIzExpecting ',' delimiter or ']')r4r r3r7) rLrMrQrRr<r4�valuesrSrArVr r r� JSONArray�s>   rZc@s<eZdZdZd dd�Zejefdd�Zdejefd d �Z dS) raSimple 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. 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)r2r=rNrOr� parse_floatr:� parse_int� _CONSTANTS� __getitem__�parse_constantr>rWZ parse_objectrZZ parse_arrayr Z parse_stringrPr rM)�selfr=rNr[r\r_r>rOr r r�__init__.s.   zJSONDecoder.__init__cCsX|rt|t�r|�|j�}|�|�\}}|||���}|t|�krTtd||t|���|S)zzReturn the Python representation of ``s`` (a ``str`` or ``unicode`` instance containing a JSON document) z Extra data)r6rrr=� raw_decoder4r9r )r`r<rQr@�objr4r r rrks  zJSONDecoder.decodercCs�|dkrtd||��|r*t|t�s*td��t|�|krxt||�}|dkrT|d7}n$|dkrx|||d�dkrx|d7}|j||||���d �S) a�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. rzExpecting valuez$Input string must be text, not bytesi��r���u)�idx)r r6r� TypeErrorr9�ordrMr4)r`r<rfrQr@Zord0r r rrbxs     zJSONDecoder.raw_decode)NNNNNTN) �__name__� __module__� __qualname__�__doc__ra� WHITESPACE�matchrrrbr r r rrs  ; )*rlZ __future__r�rerr�compatrrrrr�scannerr r rZ c_scanstring�__all__�VERBOSE� MULTILINE�DOTALL�FLAGSrrZPosInfZNegInfr]�compileZ STRINGCHUNKZ BACKSLASHr2rn�join� maxunicoderFr rmZWHITESPACE_STRrWrZ�objectrr r r r�<module>s:   $V  \$