
    Mh                         d Z ddlZddlZddlZddlmZ ddlmZ d ej        D             Z	ddZ
 G d dej                  Z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
    {
        foo: 'bar',
    }
    $ echo '{foo:"bar"}' | python -m json5 --as-json
    {
        "foo": "bar"
    }
    N)Host)__version__c                     i | ]
}|j         |S  )value).0qs     J/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/json5/tool.py
<dictcomp>r   $   s    555q555    c                    |pt                      }t          ||           }|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        j        j        |_        t!          j        ||j                  }t!          j        ||j
        |j        |j        t0          |j                           }|                    |           dS )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_DOUBLEr   r   loadsr   dumpsQUOTE_STYLES)argvhostargsinpobjss         r
   mainr,   '   sb   >466DtT""D| 

;qx -h	c		joo!!$),,{f	dk**DKK 	 	 	D	 | @$ +9?
+c$+
.
.
.C{?, !12	 	 	A 	JJqMMM1s   &C   
CC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                 H    || _          t                      j        di | d S )Nr   )r'   super__init__)selfr'   kwargs	__class__s      r
   r1   z_HostedArgumentParser.__init__S   s-    	""6"""""r   r   Nc                 r    |r |                      || j        j                   t          j        |           d S N)_print_messager'   stderrsysexit)r2   statusmessages      r
   r:   z_HostedArgumentParser.exitW   s;     	;)9:::r   c                     | j                             d| j         d| j         j                   | j                             d| j         j                   |                     dd| d           d S )	Nzusage:  )endr   z    -h/--help for help
r      zerror: 
)r'   r   usager8   r:   )r2   r<   s     r
   errorz_HostedArgumentParser.error\   sp    	.$*..BTY=MNNN	29IJJJ		!*w***+++++r   c                 b    | j                             |                                 |           d S )Nr@   )r'   r   format_help)r2   r   s     r
   
print_helpz _HostedArgumentParser.print_helpa   s,    	((**66666r   )r   Nr6   )	__name__
__module____qualname____doc__r1   r:   rD   rG   __classcell__)r4   s   @r
   r.   r.   P   su        ??# # # # #   
, , ,
7 7 7 7 7 7 7 7r   r.   c                    d}t          | d|t          t          j                  }|                    ddd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*           |                    d+d,dd-(           |                    d.d/d0t                                          d12           |                    d3d4d5d6d78           |                    |          S )9Nzjson5 [options] [FILE]
r    )progrC   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destrT   z	--as-jsonr   store_constTFz:output as JSON (same as --quote-keys --no-trailing-commas))rW   rS   constdefaultrT   z--indentr      z0amount to indent each line (default is 4 spaces))rW   rZ   rT   z--quote-keyszquote all object keys)rS   rZ   rT   z--no-quote-keysstore_falser   zBdon't quote object keys that are identifiers (this is the default))rS   rW   rT   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)rW   rS   rT   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"))rS   rZ   choicesrT   r   FILE?r   z`optional file to read JSON5 document from; if not specified or "-", will read from stdin instead)rV   nargsrZ   rT   )	r.   rK   argparseRawDescriptionHelpFormatteradd_argumentr   r%   keys
parse_args)r'   r&   rC   parsers       r
   r   r   e   sv   &E" <  F :K:::	     I	     I     ?	     $	     !	     3	     '	     	     @	     !!##*          T"""r   __main__)NN)rK   rc   r9   r    
json5.hostr   json5.versionr   r!   r%   r,   ArgumentParserr.   r   rH   r:   r   r   r
   <module>rm      s      



        % % % % % %55E$4555& & & &R7 7 7 7 7H3 7 7 7*]# ]# ]#@ zCHTTVV r   