bgq dZddlmZddlZddlmZddlZddlmZm Z m Z m Z m Z dZ e \ZZddlmZdd lmZejd Zejd Zejd Zd dddddddZedD]%Zeeedefz&[eZe dfdZe fdZ epe Z!Gdde"Z#Gdde#Z$e e%e de&e'e(e e)e*e+e,e-f dZ.dS)zImplementation of JSONEncoder )absolute_importN) itemgetter) binary_type text_type string_types integer_typesPY3cN ddlm}|j|jfS#t$rYdSwxYw)Nr _speedups)NN)r encode_basestring_ascii make_encoder ImportErrorr s I/opt/cloudlinux/venv/lib64/python3.11/site-packages/simplejson/encoder.py_import_speedupsr sL0)2HHH zzs  $$)PosInf)RawJSONz[\x00-\x1f\\"]z([\\"]|[^\ -~])z [\x80-\xff]z\\z\"z\bz\fz\nz\rz\t)\"    \u%04xrcV|rWt|trt|d}nt|turt|}nt|tr+t |t|d}nmt|ttfvrPt|trt|}n t|d}d}|t ||z|zS)z5Return a JSON representation of a Python string utf-8NrcBt|dS)Nr) ESCAPE_DCTgroup)matchs rreplacez"encode_basestring..replace=s%++a..))) isinstancebytesstrtype__str__HAS_UTF8searchunicode__getnewargs__ESCAPEsub)s_PY3_qr%s rencode_basestringr5's 1 a   AwAA !WWC   AA a   1(//!"4"4"@7##AA !WWS'N * *!S!! 1KKNN**1--a0***  7A&& & ++r&cp|rWt|trt|d}nt|turt|}nt|tr+t |t|d}nmt|ttfvrPt|trt|}n t|d}d}dtt ||zdzS)zAReturn an ASCII-only JSON representation of a Python string r Nrc|d} t|S#t$r?t|}|dkrd|fzcYS|dz}d|dz dzz}d|dzz}d||fzcYSwxYw) Nriri iiz \u%04x\u%04x)r#r"KeyErrorord)r$r2ns1s2s rr%z+py_encode_basestring_ascii..replaceXs KKNN 3a=  3 3 3AA7{{ A4''''W R501q5y)'2r(2222 3s $%A- A-,A-r) r'r(r)r*r+r,r-r.r/ ESCAPE_ASCIIr1)r2r3r%s rpy_encode_basestring_asciir?Bs 1 a   AwAA !WWC   AA a   1(//!"4"4"@7##AA !WWS'N * *!S!! 1KKNN**1--a0333 \%%gq1122 2S 88r&cBeZdZdZdZdZ d dZd Zd Zd Z dS) JSONEncoderaZExtensible JSON encoder for Python data structures. Supports the following objects and types by default: +-------------------+---------------+ | Python | JSON | +===================+===============+ | dict, namedtuple | object | +-------------------+---------------+ | list, tuple | array | +-------------------+---------------+ | str, unicode | string | +-------------------+---------------+ | int, long, 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: FTNr cf||_||_||_||_||_| |_| |_| |_||_| |_ ||_ ||_ ||_ ||_ |t|ts|dz}||_||\|_|_n |d|_| | |_||_dS)aConstructor for JSONEncoder, with sensible defaults. If skipkeys is false, then it is a TypeError to attempt encoding of keys that are not str, int, long, 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 unicode characters escaped. If ensure_ascii is false, the output will be unicode object. 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 (default: False), then out of range float values (nan, inf, -inf) will be serialized to their JavaScript equivalents (NaN, Infinity, -Infinity) instead of raising a ValueError. See ignore_nan for ECMA-262 compliant behavior. 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 string, then JSON array elements and object members will be pretty-printed with a newline followed by that string repeated for each level of nesting. ``None`` (the default) selects the most compact representation without any newlines. For backwards compatibility with versions of simplejson earlier than 2.1.0, an integer is also accepted and is converted to a string with that many spaces. 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``. If encoding is not None, then all input strings will be transformed into unicode using that encoding prior to JSON-encoding. The default is UTF-8. If use_decimal is true (default: ``True``), ``decimal.Decimal`` will be supported directly by the encoder. For the inverse, decode JSON with ``parse_float=decimal.Decimal``. If namedtuple_as_object is true (the default), objects with ``_asdict()`` methods will be encoded as JSON objects. If tuple_as_array is true (the default), tuple (and subclasses) will be encoded as JSON arrays. If *iterable_as_array* is true (default: ``False``), any object not in the above table that implements ``__iter__()`` will be encoded as a JSON array. If bigint_as_string is true (not the default), ints 2**53 and higher or lower than -2**53 will be encoded as strings. This is to avoid the rounding that happens in Javascript otherwise. If int_as_string_bitcount is a positive number (n), then int of size greater than or equal to 2**n or lower than or equal to -2**n will be encoded as strings. If specified, item_sort_key is a callable used to sort the items in each dictionary. This is useful if you want to sort items other than in alphabetical order by key. If for_json is true (not the default), objects with a ``for_json()`` method will use the return value of that method for encoding as JSON instead of the object. If *ignore_nan* is true (default: ``False``), then out of range :class:`float` values (``nan``, ``inf``, ``-inf``) will be serialized as ``null`` in compliance with the ECMA-262 specification. If true, this will override *allow_nan*. N ,)skipkeys ensure_asciicheck_circular allow_nan sort_keys use_decimalnamedtuple_as_objecttuple_as_arrayiterable_as_arraybigint_as_string item_sort_keyfor_json ignore_nanint_as_string_bitcountr'rindentitem_separator key_separatordefaultencoding)selfrErFrGrHrIrS separatorsrWrVrJrKrLrNrOrPrQrRrMs r__init__zJSONEncoder.__init__sr! (,""&$8!,!2 0*  $&<#  j&F&F c\F  !6@ 3D !3!3  "%D   "DL  r&c:td|jjz)a$Implement 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) return JSONEncoder.default(self, o) z*Object of type %s is not JSON serializable) TypeError __class____name__)rXos rrVzJSONEncoder.defaults&$D ,-.. .r&ct|tr|j}||dkst||}t|tr%|jrt |St|S||}t|ttfst|}|jrd |Sd |S)zReturn a JSON string representation of a Python data structure. >>> from simplejson import JSONEncoder >>> JSONEncoder().encode({"foo": ["bar", "baz"]}) '{"foo": ["bar", "baz"]}' Nr r) r'rrWrrrFrr5 iterencodelisttuplejoin)rXr_ _encodingchunkss rencodezJSONEncoder.encodes a % % , I%yG/C/Ca++ a & & ,  ,.q111(+++##&4-00 "&\\F   $776?? "88F## #r&cB|jri}nd}|jrt}nt}|jdkr|j ||jfd}|j|jttt fd}i}|j rdn|j }t|j xt||j ||j |j|j|j|j|j||j|j|j||j|j|j|jt.j|j}nlt5||j ||j ||j|j|j|j|j|j|j||j|j|j|jt.j} ||d|S#|wxYw)zEncode the given object and yield each string representation as available. For example:: for chunk in JSONEncoder().iterencode(bigobject): mysocket.write(chunk) Nr cbt|trt||}||SN)r'rr)r_ _orig_encoderres r_encoderz(JSONEncoder.iterencode.._encoderEs3a--0!!Y//A$}Q'''r&c||krd}nD||krd}n;||krd}n2t|tkrt|}||S|rd}n!|stdt|z|S)NNaNInfinityz -Infinitynullz2Out of range float values are not JSON compliant: )r*float ValueErrorrepr)r_rHrQ_repr_inf_neginftexts rfloatstrz(JSONEncoder.iterencode..floatstrJs Avvd!g"77e##aAuQxx   HGGKr&5)Decimalr)rGrFrr5rWrHrQ FLOAT_REPRrrNrRc_make_encoderrSrVrUrTrIrErJrKrLrOrPdecimalrzrM_make_iterencodeclear)rXr_markersrlrxkey_memorR _iterencodes rrazJSONEncoder.iterencode2s   GGG   ).HH(H =G # # (A*2dm ( ( ( ( #'.T_ vw    6' HBBT-H   &4;+>(x"D$7 t~x9I)4+>&"DM4=$2HJJKK+xh"D$7 t/)4+>&"DM4=&AAAK ;q!$$ NN    HNN    s ( FF)FTTFFNNr NTTTFNFFNF) r^ __module__ __qualname____doc__rTrUrZrVrgrar&rrArAns8NM48AFIM8<7<@E@E p!p!p!p!d...*$$$:KKKKKr&rAc(eZdZdZdZfdZxZS)JSONEncoderForHTMLa3An encoder that produces JSON safe to embed in HTML. To embed JSON content in, say, a script tag on a web page, the characters &, < and > should be escaped. They cannot be escaped with the usual entities (e.g. &) because they are not expanded within