a
    õ£Bej  ã                   @   s^   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d	„Z	e
d
krZe e	ƒ ¡ dS )zÜA 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                 C   sŽ  |pt ƒ }tj|dtd�}|jddddd� |jdd	d
dddd� |jddddd� |jddddd� |jddddd� |jddddd� |jdd dd!d"� |jd#d$d%d&d'd(� | | ¡}|jd urÊ|jS |jrÞ| t	¡ d)S |j
rì|j
}n$|jd&k�r|j ¡ }n| |j¡}|jd*k�r$d |_n&zt|jƒ|_W n t�yH   Y n0 |j�r^d|_d|_t |¡}tj||j|j|jd+�}| |¡ d)S ),NZjson5)ÚprogÚdescz-cZ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_argsZexit_statusÚversionÚprint_r   r	   r   ÚstdinÚreadZread_text_filer   ÚintÚ
ValueErrorr   r   r   r   ÚloadsÚdumps)ÚargvÚhostÚparserÚargsÚinpÚobjÚs© r1   úM/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/json5/tool.pyÚmain%   st    

ÿ
þ
ÿ
ÿþþþÿ



ý
r3   Ú__main__)NN)r   ÚsysÚ r   r   r+   r   r"   r   r3   Ú__name__Úexitr1   r1   r1   r2   Ú<module>   s   
E