o 7]h @svddlmZmZddlmZmZmZmZddlm Z ddl m Z m Z GdddZ edkrdd lZdd lZejd d Zejd d ddejdddedddeZddlmZeZeddZz'ejdkrlejZneejd Z e ZWd n1swYWn#e!yZ"ze#dejde"e$dWYd Z"["nd Z"["wwej#e eej%dddd Sd S) )loadsdumps)AnyCallableOptionalUnion)Text)JSONHighlighterNullHighlighterc@seZdZdZ        ddededeefded ed ed ed ed ee e ge fdeddfddZ e        dde dedeefded ed ed ed ed ee e ge fdeddfddZ defddZdS)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. TFNjsonindent highlight skip_keys ensure_asciicheck_circular allow_nandefault sort_keysreturnc CsNt|} t| ||||||| d}|rtnt} | ||_d|j_d|j_dS)NrskipkeysrrrrrT)rrr r textno_wrapoverflow) selfrrrrrrrrrdata highlighterr 7/usr/lib/python3/dist-packages/pip/_vendor/rich/json.py__init__s   z JSON.__init__rc CsP||} t|||||||| d} |rtnt} | | | _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) clsrrrrrrrrr json_instancerrr r r! from_data4s  zJSON.from_datacCs|jS)N)r)rr r r!__rich__dsz JSON.__rich__)r TFTTTNF)__name__ __module__ __qualname____doc__strrintboolrrrr" classmethodr&r r'r r r r!r s|        /r __main__NzPretty print json) descriptionpathPATHzpath to file, or - for stdin)metavarhelpz-iz--indentSPACESzNumber of spaces in an indentr )r4typer5r)ConsoleT)stderr-rtzUnable to read z; )r) soft_wrap)&rrrtypingrrrrrr rr r r r(argparsesysArgumentParserparser add_argumentr- parse_argsargspip._vendor.rich.consoler8console error_consoler2stdinread json_dataopen json_file Exceptionerrorprintexitrr r r r!sP `