=Og> dZddlZ ddlmZn #e$rdZYnwxYw ddlmZn #e$rdZYnwxYw ddlmZ n #e$rdZ YnwxYwej dZ ej dZ ej dZ d d d d d dddZedD]4Zeeede5[edZdZepeZdZepeZGddeZeeeeeeee e!ej"f dZ#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)\"    \u{0:04x}infcJd}dt||zdzS)z5Return a JSON representation of a Python string cBt|dS)Nr) ESCAPE_DCTgroup)matchs 3/opt/alt/python311/lib64/python3.11/json/encoder.pyreplacez%py_encode_basestring..replace)s%++a..))r)ESCAPEsubsrs rpy_encode_basestringr%s/*** GQ'' '# --rcJd}dt||zdzS)zAReturn an ASCII-only JSON representation of a Python string c|d} t|S#t$r]t|}|dkrd|cYS|dz}d|dz dzz}d|dzz}d||cYSwxYw) Nriri iiz\u{0:04x}\u{1:04x})rrKeyErrorordformat)rrns1s2s rrz+py_encode_basestring_ascii..replace5s KKNN =a=  = = =AA7{{#**1-----W R501q5y)-44R<<<<< =s $4B .B  B r) ESCAPE_ASCIIrrs rpy_encode_basestring_asciir'1s3=== !!'1-- - 33rc HeZdZdZdZdZddddddddddZd Zd Zd d Z dS) JSONEncodera[Extensible JSON 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_asciicheck_circular allow_nan sort_keysindent separatorsdefaultc||_||_||_||_||_||_||\|_|_n |d|_| ||_dSdS)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, 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 RecursionError). 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_separatorr1) selfr*r+r,r-r.r/r0r1s r__init__zJSONEncoder.__init__isqV! (,""  !6@ 3D !3!3  "%D   "DLLL  rc<td|jjd)abImplement 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 super().default(o) zObject of type z is not JSON serializable) TypeError __class____name__)r6os rr1zJSONEncoder.defaults1&4!+*>44455 5rc$t|tr%|jrt|St |S||d}t|t tfst |}d|S)zReturn 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) isinstancestrr+rr iterencodelisttuplejoin)r6r<chunkss rencodezJSONEncoder.encodes a   ,  ,.q111(+++d33&4-00 "&\\Fwwvrc |jri}nd}|jrt}nt}|jt jtt fd}|rItB|j ;t||j ||j |j |j |j |j|j }n6t||j ||j ||j |j |j |j| }||dS)zEncode the given object and yield each string representation as available. For example:: for chunk in JSONEncoder().iterencode(bigobject): mysocket.write(chunk) Nc||krd}n||krd}n||krd}n ||S|stdt|z|S)NNaNInfinityz -Infinityz2Out of range float values are not JSON compliant: ) ValueErrorrepr)r<r-_repr_inf_neginftexts rfloatstrz(JSONEncoder.iterencode..floatstrss Avvd!g"uQxx  HGGKrr)r,r+rrr-float__repr__INFINITYc_make_encoderr/r1r5r4r.r*_make_iterencode)r6r<r>markers_encoderrR _iterencodes rrBzJSONEncoder.iterencodes   GGG   ).HH(H"&.n8hY    .  *.4K'(x"D$7 t~//KK +xh"D$7 y**K{1a   r)F) r; __module__ __qualname____doc__r4r5r7r1rGrBrrr)r)Js8NM#(t45D$6#6#6#6#6#p555,,5!5!5!5!5!5!rr)c sdz  fd  fd  fdS)N c3|K|sdVdS|}|vr  d||<d} |dz }d |zz}|z}||z }nd}}d}|D]}|rd}n|}|r| |zV&||dzV0|dur|d zV<|dur|d zVH|r| |zVe|r| |zV|V|fr ||}n%|r ||}n ||}|Ed{V||dz}d |zzVd V|=dSdS) Nz[]Circular reference detected[r TFnulltruefalse]r^)lst_current_indent_levelmarkeridbufnewline_indent separatorfirstvaluerFrLrY _floatstr_indent_intstr_item_separatorrZ_iterencode_dict_iterencode_listdictrSidintr@rCrXrArDs rrvz*_make_iterencode.._iterencode_lists JJJ F  r#wwH7"" j!>??? #GH    !Q & !!G.C$CCN'.8I > !CC!N'I " "E z%%% "HHUOO+++++Fl""""$Fl""""%Gm####E3'' "GGENN*****E5)) "IIe,,,,,,, :edE]33G--e5JKKFFZt,,G--e5JKKFF([0EFFF!!!!!!!!!  % !Q & !#888 8 8 8  !!!  rc3K|sdVdS|}|vr  d||<dV |dz }d |zz}|z}|Vnd}}d}r"t|}n|}|D]>\}}|rnb|r  |}nJ|durd}nC|durd }n<|d }n7|r |}nrYtd |jj|rd}n|V |VV|r |V|d V|durdV|durd V|r|V|r |V|fr ||} n%|r ||} n ||} | Ed{V@||dz}d |zzVd V|=dSdS) Nz{}rb{rdr TrfFrgrez0keys must be str, int, float, bool or None, not })sorteditemsr9r:r;)dctrjrkrmr4ror~keyrprFrLrYrqrrrsrtrZrurv_key_separator _skipkeys _sort_keysrwrSrxryr@rCrXrArDs rruz*_make_iterencode.._iterencode_dictNsx JJJ F  r#wwH7"" j!>??? #GH    !Q & !!G.C$CCN,~=N !N,N  399;;''EEIIKKE1 "1 "JCz#s## AC'' AinnC%% Agcll A!@'*}'=!@!@AAA %$$$$(3--    z%%% "huoo%%%% $ % E3'' "genn$$$$E5)) "i&&&&&&:edE]33G--e5JKKFFZt,,G--e5JKKFF([0EFFF!!!!!!!!!  % !Q & !#888 8 8 8  !!!  rc3K|r|VdS|dVdS|durdVdS|durdVdS|r|VdS| r|VdS|fr ||Ed{VdS| r ||Ed{VdS |}|vr d||<|}||Ed{V|=dSdS)NreTrfFrgrbr^)r<rjrkrL_defaultrYrqrsrZrurvrwrSrxryr@rCrXrArDs rrZz%_make_iterencode.._iterencodes :a   &(1++      YLLLLL $YYLLLLL %ZZMMMMM Z3   &'!**      Z5 ! ! &)A,,      ZD%= ) ) &''+@AA A A A A A A A A A Z4 &''+@AA A A A A A A A A A"2a55w&&$*%BCCC$%! A"{1&;<< < < < < < < <"H%%%#"rr^)rXrrYrrrqrrtrrr>rLrwrSrxryr@rCrArDrsrZrurvs````````` ``````````@@@rrWrWs::gs#;#;-6"6"6"6"6"6"6"6"6"6"6"6"6"6"6"6"6"6"6"6"6"6"pN"N"N"N"N"N"N"N"N"N"N"N"N"N"N"N"N"N"N"N"N"N"N"N"N"`&&&&&&&&&&&&&&&&&&&&&: r)$r]re_jsonrc_encode_basestring_ascii ImportErrorrc_encode_basestringrrVcompilerr&HAS_UTF8rrangei setdefaultchrr"rSrUrr'objectr)rLrwrxryr@rCrArDrTrWr^rrrs= %JJJJJJJ%%% $%>>>>>>>4444444NNN / 0 0rz,-- 2:n % %         t::A##a&&,"5"5a"8"89999 5<<...)@,@444.;!;x!x!x!x!x!&x!x!x!z     wwwwwws'$..9AA