
    `j                         d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ d
dZ	e
d	k    r ej         e	                       dS dS )zA tool to parse and pretty-print JSON5.

Usage:

    $ echo '{foo:"bar"}' | python -m json5.tool
    {
        foo: 'bar',
    }
    $ echo '{foo:"bar"}' | python -m json5.tool --as-json
    {
        "foo": "bar"
    }
    N   )
arg_parser)lib)Host)VERSIONc                 b   |pt                      }t          j        |dt                    }|                    dddd           |                    dd	d
ddd           |                    dddd           |                    dddd           |                    dddd           |                    dddd           |                    dd dd!"           |                    d#d$d%d&d'(           |                    |           }|j        |j        S |j        r|                    t                     d)S |j
        r|j
        }n?|j        d&k    r|j                                        }n|                    |j                  }|j        d*k    rd |_        n+	 t!          |j                  |_        n# t"          $ r Y nw xY w|j        rd|_        d|_        t+          j        |          }t+          j        ||j        |j        |j        +          }|                    |           d)S ),Njson5)progdescz-cSTRcmdz:inline json5 string to read instead of reading from a file)metavardesthelpz	--as-jsonas_jsonstore_constTFz:output as JSON (same as --quote-keys --no-trailing-commas))r   actionconstdefaultr   z--indentindent   z0amount to indent each line (default is 4 spaces))r   r   r   z--quote-keys
store_truezquote all object keys)r   r   r   z--no-quote-keysstore_false
quote_keyszBdon't quote object keys that are identifiers (this is the default))r   r   r   z--trailing-commaszUadd commas after the last item in multi-line objects and arrays (this is the default)z--no-trailing-commastrailing_commaszEdo not add commas after the last item in multi-line lists and objects)r   r   r   fileFILE?-z`optional file to read JSON5 document from; if not specified or "-", will read from stdin instead)r   nargsr   r   r   None)r   r   r   )r   r   ArgumentParser__doc__add_argument
parse_argsexit_statusversionprint_r   r   r   stdinreadread_text_filer   int
ValueErrorr   r   r   r   loadsdumps)argvhostparserargsinpobjss          *lib/python3.11/site-packages/json5/tool.pymainr8   %   s   >466D&t'HHHF
e%3  4 4 4 )M"EK  L L L 
15  6 6 6 |U4  6 6 6
)-)6  7 7 7 +L $H  I I I .5F,<  = = = c3'  ( ( ( T""D%!!| Gqx -h	c		joo!!$),,{f	dk**DKK 	 	 	D	 | %$
)C..C	#!_"&"6	8 	8 	8A 	KKNNN1s    F: :
GG__main__)NN)r#   sys r   r   r1   r   r'   r   r8   __name__exit     r7   <module>r@      s     


                        B B B BJ zCHTTVV r?   