U ʗRe @s`ddlmZmZddlmZmZmZmZddlm Z ddl m Z m Z GdddZ edkr\dd lZdd lZejd d Zejd d ddejdddedddeZddlmZeZeddZz:ejdkrejZn eejdZ e ZW5QRXWnFe!k rBZ"z&e#dejde"e$dW5d Z"["XYnXej#e eej%dddd S) )loadsdumps)AnyCallableOptionalUnion)Text)JSONHighlighterNullHighlighterc @seZdZdZdeedeefeeeeeee e ge fedd ddZ e de edeefeeeeeee e ge fedd d d Z ed d 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_keys ensure_asciicheck_circular allow_nandefault sort_keysreturnc CsNt|} t| ||||||| d}|r*tnt} | ||_d|j_d|j_dS)NrskipkeysrrrrrT)rrr r textno_wrapoverflow) selfrrrrrrrrrdata highlighterr /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__) rrrrrrrrrrc CsP||} t|||||||| d} |r,tnt} | | | _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. rTN)__new__rr r rrr) clsrrrrrrrrrZ json_instancerrr r r! from_data4s    zJSON.from_data)rcCs|jS)N)r)rr r r!__rich__dsz JSON.__rich__)r TFTTTNF)r TFTTTNF)__name__ __module__ __qualname____doc__strrintboolrrrr" classmethodr%r r&r r r r!r sV   /r __main__NzPretty print json) descriptionpathPATHzpath to file, or - for stdin)metavarhelpz-iz--indentZSPACESzNumber of spaces in an indentr )r3typer4r)ConsoleT)stderr-rtzUnable to read z; )r) soft_wrap)&rrrtypingrrrrrr rr r r r'argparsesysArgumentParserparser add_argumentr, parse_argsargspip._vendor.rich.consoler6consoleZ error_consoler1stdinreadZ json_dataopenZ json_file Exceptionerrorprintexitrr r r r!sD `