U ʗRe @ s` d dl mZmZ d dlmZmZmZmZ ddlm Z ddl mZmZ G dd dZ edkr\d d lZd d lZejd dZejdd dd ejdddeddd e Zd dlmZ e ZeddZz:ejdkrej Zn eejdZ e ZW 5 Q R X W nF e!k rB Z" z&e#dejde" e$d W 5 d Z"["X Y nX ej#e eej%ddd d S ) )loadsdumps)AnyCallableOptionalUnion )Text)JSONHighlighterNullHighlighterc @ s e Zd ZdZdeedeef eeeeeee e ge f edd ddZede edeef eeeeeee e ge f ed d d dZ edd dZdS )JSONa_ A renderable which pretty prints JSON. Args: json (str): JSON encoded data. indent (Union[None, int, str], optional): Number of characters to indent by. Defaults to 2. highlight (bool, optional): Enable highlighting. Defaults to True. skip_keys (bool, optional): Skip keys not of a basic type. Defaults to False. ensure_ascii (bool, optional): Escape all non-ascii characters. Defaults to False. check_circular (bool, optional): Check for circular references. Defaults to True. allow_nan (bool, optional): Allow NaN and Infinity values. Defaults to True. default (Callable, optional): A callable that converts values that can not be encoded in to something that can be JSON encoded. Defaults to None. sort_keys (bool, optional): Sort dictionary keys. Defaults to False. TFN) jsonindent highlight skip_keysensure_asciicheck_circular allow_nandefault sort_keysreturnc C sN t |} t| ||||||| d}|r*t nt }||| _d| j_d | j_d S )Nr skipkeysr r r r r T)r r r r textno_wrapoverflow)selfr r r r r r r r r datahighlighter r /builddir/build/BUILDROOT/alt-python38-pip-22.2.1-2.el8.x86_64/opt/alt/python38/lib/python3.8/site-packages/pip/_vendor/rich/json.py__init__ s z JSON.__init__) r r r r r r r r r r c C sP | | } t|||||||| d}|r,t nt }||| _d| j_d| j_| S )a| Encodes a JSON object from arbitrary data. Args: data (Any): An object that may be encoded in to JSON indent (Union[None, int, str], optional): Number of characters to indent by. Defaults to 2. highlight (bool, optional): Enable highlighting. Defaults to True. default (Callable, optional): Optional callable which will be called for objects that cannot be serialized. Defaults to None. skip_keys (bool, optional): Skip keys not of a basic type. Defaults to False. ensure_ascii (bool, optional): Escape all non-ascii characters. Defaults to False. check_circular (bool, optional): Check for circular references. Defaults to True. allow_nan (bool, optional): Allow NaN and Infinity values. Defaults to True. default (Callable, optional): A callable that converts values that can not be encoded in to something that can be JSON encoded. Defaults to None. sort_keys (bool, optional): Sort dictionary keys. Defaults to False. Returns: JSON: New JSON object from the given data. r TN)__new__r r r r r r ) clsr r r r r r r r r Z json_instancer r r r r! from_data4 s zJSON.from_data)r c C s | j S )N)r )r r r r! __rich__d s z JSON.__rich__)r TFTTTNF)r TFTTTNF)__name__ __module____qualname____doc__strr intboolr r r r" classmethodr% r r&