Hacked By AnonymousFox

Current Path : /opt/alt/python36/lib64/python3.6/json/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/json/__pycache__/encoder.cpython-36.pyc

3

� f�>�"@sBdZddlZyddlmZWnek
r4dZYnXyddlmZWnek
r^dZYnXyddlmZ	Wnek
r�dZ	YnXej
d�Zej
d�Zej
d�Z
d	d
ddd
ddd�Zx&ed�D]Zejee�dje��q�Wed�Zdd�Zep�eZdd�Ze�peZGdd�de�Zeeeeeeee e!ej"f
dd�Z#dS)zImplementation of JSONEncoder
�N)�encode_basestring_ascii)�encode_basestring)�make_encoderz[\x00-\x1f\\"\b\f\n\r\t]z([\\"]|[^\ -~])s[�-�]z\\z\"z\bz\fz\nz\rz\t)�\�"���
�
�	� z	\u{0:04x}�infcCsdd�}dtj||�dS)z5Return a JSON representation of a Python string

    cSst|jd�S)Nr)�
ESCAPE_DCT�group)�match�r�1/opt/alt/python36/lib64/python3.6/json/encoder.py�replace(sz%py_encode_basestring.<locals>.replacer)�ESCAPE�sub)�srrrr�py_encode_basestring$srcCsdd�}dtj||�dS)zAReturn an ASCII-only JSON representation of a Python string

    cSsv|jd�}yt|Stk
rpt|�}|dkr<dj|�S|d8}d|d?d@B}d|d@B}dj||�SYnXdS)	Nriz	\u{0:04x}i��
i�i�z\u{0:04x}\u{1:04x})rr�KeyError�ord�format)rr�n�s1�s2rrrr4s

z+py_encode_basestring_ascii.<locals>.replacer)�ESCAPE_ASCIIr)rrrrr�py_encode_basestring_ascii0sr c	@sNeZdZdZdZdZddddddddd�dd	�Zd
d�Zdd
�Zddd�Z	dS)�JSONEncoderaZExtensible JSON <http://json.org> encoder for Python data structures.

    Supports the following objects and types by default:

    +-------------------+---------------+
    | Python            | JSON          |
    +===================+===============+
    | dict              | object        |
    +-------------------+---------------+
    | list, tuple       | array         |
    +-------------------+---------------+
    | str               | string        |
    +-------------------+---------------+
    | int, float        | number        |
    +-------------------+---------------+
    | True              | true          |
    +-------------------+---------------+
    | False             | false         |
    +-------------------+---------------+
    | None              | null          |
    +-------------------+---------------+

    To extend this to recognize other objects, subclass and implement a
    ``.default()`` method with another method that returns a serializable
    object for ``o`` if possible, otherwise it should call the superclass
    implementation (to raise ``TypeError``).

    z, z: FTN)�skipkeys�ensure_ascii�check_circular�	allow_nan�	sort_keys�indent�
separators�defaultc	CsZ||_||_||_||_||_||_|dk	r:|\|_|_n|dk	rHd|_|dk	rV||_dS)a�Constructor for JSONEncoder, with sensible defaults.

        If skipkeys is false, then it is a TypeError to attempt
        encoding of keys that are not str, int, float or None.  If
        skipkeys is True, such items are simply skipped.

        If ensure_ascii is true, the output is guaranteed to be str
        objects with all incoming non-ASCII characters escaped.  If
        ensure_ascii is false, the output can contain non-ASCII characters.

        If check_circular is true, then lists, dicts, and custom encoded
        objects will be checked for circular references during encoding to
        prevent an infinite recursion (which would cause an OverflowError).
        Otherwise, no such check takes place.

        If allow_nan is true, then NaN, Infinity, and -Infinity will be
        encoded as such.  This behavior is not JSON specification compliant,
        but is consistent with most JavaScript based encoders and decoders.
        Otherwise, it will be a ValueError to encode such floats.

        If sort_keys is true, then the output of dictionaries will be
        sorted by key; this is useful for regression tests to ensure
        that JSON serializations can be compared on a day-to-day basis.

        If indent is a non-negative integer, then JSON array
        elements and object members will be pretty-printed with that
        indent level.  An indent level of 0 will only insert newlines.
        None is the most compact representation.

        If specified, separators should be an (item_separator, key_separator)
        tuple.  The default is (', ', ': ') if *indent* is ``None`` and
        (',', ': ') otherwise.  To get the most compact JSON representation,
        you should specify (',', ':') to eliminate whitespace.

        If specified, default is a function that gets called for objects
        that can't otherwise be serialized.  It should return a JSON encodable
        version of the object or raise a ``TypeError``.

        N�,)	r"r#r$r%r&r'�item_separator�
key_separatorr))	�selfr"r#r$r%r&r'r(r)rrr�__init__hs+zJSONEncoder.__init__cCstd|jj��dS)alImplement this method in a subclass such that it returns
        a serializable object for ``o``, or calls the base implementation
        (to raise a ``TypeError``).

        For example, to support arbitrary iterators, you could
        implement default like this::

            def default(self, o):
                try:
                    iterable = iter(o)
                except TypeError:
                    pass
                else:
                    return list(iterable)
                # Let the base class default method raise the TypeError
                return JSONEncoder.default(self, o)

        z,Object of type '%s' is not JSON serializableN)�	TypeError�	__class__�__name__)r-�orrrr)�szJSONEncoder.defaultcCsNt|t�r |jrt|�St|�S|j|dd�}t|ttf�sDt|�}dj|�S)z�Return a JSON string representation of a Python data structure.

        >>> from json.encoder import JSONEncoder
        >>> JSONEncoder().encode({"foo": ["bar", "baz"]})
        '{"foo": ["bar", "baz"]}'

        T)�	_one_shot�)	�
isinstance�strr#rr�
iterencode�list�tuple�join)r-r2�chunksrrr�encode�s	
zJSONEncoder.encodecCs�|jri}nd}|jrt}nt}|jtjttfdd�}|rvtdk	rv|j	dkrvt||j
||j	|j|j|j
|j|j�	}n&t||j
||j	||j|j|j
|j|�
}||d�S)z�Encode the given object and yield each string
        representation as available.

        For example::

            for chunk in JSONEncoder().iterencode(bigobject):
                mysocket.write(chunk)

        NcSsJ||krd}n$||krd}n||kr*d}n||�S|sFtdt|���|S)NZNaNZInfinityz	-Infinityz2Out of range float values are not JSON compliant: )�
ValueError�repr)r2r%Z_reprZ_infZ_neginf�textrrr�floatstr�sz(JSONEncoder.iterencode.<locals>.floatstrr)r$r#rrr%�float�__repr__�INFINITY�c_make_encoderr'r)r,r+r&r"�_make_iterencode)r-r2r3�markers�_encoderr@�_iterencoderrrr7�s&


zJSONEncoder.iterencode)F)
r1�
__module__�__qualname__�__doc__r+r,r.r)r<r7rrrrr!Is6r!cs��dk	r����rd�����������	�
��������fdd��	���������	�
���
��������fdd����������	�
��������fdd���S)N� c	3s�|sdVdS�dk	r6�|�}|�kr.�d��|�|<d}�dk	rh|d7}d�|}�|}||7}nd}�}d}x�|D]�}|r�d}n|}�
|��r�|�|�Vqz|dkr�|dVqz|dkr�|d	Vqz|dkr�|d
Vqz�
|��r�|�|�Vqz�
|�
��r|�|�Vqz|V�
|��f��r:�||�}n"�
|�	��rR�||�}n
�||�}|EdHqzW|dk	�r�|d8}d�|VdV�dk	�r��|=dS)Nz[]zCircular reference detected�[�r	TF�null�true�false�]r)	Zlst�_current_indent_level�markeridZbuf�newline_indentZ	separator�first�valuer;)r=rG�	_floatstr�_indent�_intstr�_item_separatorrH�_iterencode_dict�_iterencode_list�dictrA�id�intr5r8rFr6r9rrr]s\






z*_make_iterencode.<locals>._iterencode_listc
3sL|sdVdS�dk	r6�|�}|�kr.�d��|�|<dV�dk	rh|d7}d�|}�|}|Vnd}�}d}�r�t|j�dd�d	�}n|j�}�xx|D�]n\}}�|��r�nr�|�
�rȈ|�}n^|dkr�d
}nP|dkr�d}nB|dkr�d
}n4�|���r�|�}n�
�rq�ntdt|�d��|�r2d}n|V�|�V�	V�|���r`�|�Vq�|dk�rrd
Vq�|dk�r�d
Vq�|dk�r�dVq��|���r��|�Vq��|�
��rƈ|�Vq��|��f��r�||�}	n"�|���r��||�}	n
�||�}	|	EdHq�W|dk	�r2|d8}d�|VdV�dk	�rH�|=dS)Nz{}zCircular reference detected�{rNr	TcSs|dS)Nrr)Zkvrrr�<lambda>asz<_make_iterencode.<locals>._iterencode_dict.<locals>.<lambda>)�keyrPFrQrOzkey z is not a string�})�sorted�itemsr/r>)
ZdctrSrTrUr+rVrfrcrWr;)r=rGrXrYrZr[rHr\r]�_key_separator�	_skipkeys�
_sort_keysr^rAr_r`r5r8rFr6r9rrr\Ms�










z*_make_iterencode.<locals>._iterencode_dictc3s�|��r�|�Vn�|dkr&dVn�|dkr6dVn�|dkrFdVn��|��r\�|�Vn��|�	�rr�|�Vn��|�
�f�r��||�EdHnj�|��r��||�EdHnN�dk	rֈ
|�}|�krΈd��|�|<�|�}�||�EdH�dk	r��|=dS)NrOTrPFrQzCircular reference detectedr)r2rSrT)r=�_defaultrGrXrZrHr\r]r^rAr_r`r5r8rFr6r9rrrH�s2



z%_make_iterencode.<locals>._iterencoder)rFrjrGrYrXrgr[rirhr3r=r^rAr_r`r5r8r6r9rZr)r=rjrGrXrYrZr[rHr\r]rgrhrir^rAr_r`r5r8rFr6r9rrEs.84O,rE)$rK�reZ_jsonrZc_encode_basestring_ascii�ImportErrorrZc_encode_basestringrrD�compilerrZHAS_UTF8r�range�i�
setdefault�chrrrArCrr �objectr!r=r^r_r`r5r8r6r9�__str__rErrrr�<module>sT





	
>

Hacked By AnonymousFox1.0, Coded By AnonymousFox