
    Xh                         d Z ddlZddlZddlZddlmZ ddlmZ ej                  D  ci c]  } | j                  |  c} Z
d
dZ G d dej                        Zd Zed	k(  r ej                    e              yyc c} w )zA tool to parse and pretty-print JSON5.

Usage:

    $ echo '{foo:"bar"}' | python -m json5
    {
        foo: 'bar',
    }
    $ echo '{foo:"bar"}' | python -m json5 --as-json
    {
        "foo": "bar"
    }
    N)Host)__version__c                 6   |xs
 t               }t        ||       }|j                  r|j                  t               y|j
                  r|j
                  }nE|j                  dk(  r|j                  j                         }n|j                  |j                        }|j                  dk(  rd |_
        n	 t        |j                        |_
        |j                  r7d|_        d|_        t         j"                  j$                  j&                  |_        t!        j*                  ||j,                        }t!        j.                  ||j                  |j                  |j                  t0        |j(                           }|j                  |       y# t        $ r Y w xY w)Nr   -NoneTF)strict)indent
quote_keystrailing_commasquote_style)r   _parse_argsversionprintr   cmdfilestdinreadread_text_filer	   int
ValueErroras_jsonr
   r   json5
QuoteStyleALWAYS_DOUBLEvaluer   loadsr   dumpsQUOTE_STYLES)argvhostargsinpobjss         >/var/www/html/myenv/lib/python3.12/site-packages/json5/tool.pymainr&   '   s7   >46DtT"D||

;xxhh	c	jjoo!!$)),{{f	dkk*DK ||$ ++99??
++c$++
.C{{??,, !1!12	A 	JJqM#  		s   3F 	FFc                   8     e Zd ZdZ fdZddZd ZddZ xZS )_HostedArgumentParserz5An argument parser that plays nicely w/ host objects.c                 2    || _         t        |   di | y )N )r    super__init__)selfr    kwargs	__class__s      r%   r,   z_HostedArgumentParser.__init__S   s    	"6"    c                 ~    |r&| j                  || j                  j                         t        j                  |       y N)_print_messager    stderrsysexit)r-   statusmessages      r%   r6   z_HostedArgumentParser.exitW   s+    )9)9:r0   c                    | j                   j                  d| j                   d| j                   j                         | j                   j                  d| j                   j                         | j	                  dd| d       y )	Nzusage:  )endr   z    -h/--help for help
r      zerror: 
)r    r   usager4   r6   )r-   r8   s     r%   errorz_HostedArgumentParser.error\   sc    		'$**.BTYY=M=MN		29I9IJ		!wwir*+r0   c                 Z    | j                   j                  | j                         |       y )Nr<   )r    r   format_help)r-   r   s     r%   
print_helpz _HostedArgumentParser.print_helpa   s    		((*6r0   )r   Nr2   )	__name__
__module____qualname____doc__r,   r6   r@   rC   __classcell__)r/   s   @r%   r(   r(   P   s    ?#
,
7r0   r(   c                    d}t        | d|t        t        j                        }|j	                  ddddt
         d	       |j	                  d
ddd       |j	                  dddddd       |j	                  dddd       |j	                  dddd       |j	                  ddd d!"       |j	                  d#ddd$       |j	                  d%d&dd'(       |j	                  d)ddd*       |j	                  d+d,dd-(       |j	                  d.d/d0t        j                         d12       |j	                  d3d4d5d6d78       |j                  |      S )9Nzjson5 [options] [FILE]
r   )progr?   descriptionformatter_classz-Vz	--version
store_truezshow JSON5 library version ())actionhelpz-cSTRr   z:inline json5 string to read instead of reading from a file)metavardestrP   z	--as-jsonr   store_constTFz:output as JSON (same as --quote-keys --no-trailing-commas))rS   rO   constdefaultrP   z--indentr	      z0amount to indent each line (default is 4 spaces))rS   rV   rP   z--quote-keyszquote all object keys)rO   rV   rP   z--no-quote-keysstore_falser
   zBdon't quote object keys that are identifiers (this is the default))rO   rS   rP   z--trailing-commaszUadd commas after the last item in multi-line objects and arrays (this is the default)z--no-trailing-commasr   zEdo not add commas after the last item in multi-line lists and objects)rS   rO   rP   z--strictz@Do not allow control characters (\x00-\x1f) in strings (default)z--no-strictr   z/Allow control characters (\x00-\x1f) in stringsz--quote-stylestorealways_doublez\Controls how strings are encoded. By default they are always double-quoted ("always_double"))rO   rV   choicesrP   r   FILE?r   z`optional file to read JSON5 document from; if not specified or "-", will read from stdin instead)rR   nargsrV   rP   )	r(   rG   argparseRawDescriptionHelpFormatteradd_argumentr   r   keys
parse_args)r    r   r?   parsers       r%   r   r   e   s   &E" <<F +K=:	   I	   I   ?	   $	   !	   3	   '	   	   @	   !!#*      T""r0   __main__)NN)rG   r_   r5   r   
json5.hostr   json5.versionr   r   r   r   r&   ArgumentParserr(   r   rD   r6   )qs   0r%   <module>rj      s}     
   %$)$4$45q
5&R7H33 7*]#@ zCHHTV C 6s   A: