AlkantarClanX12
Current Path : /opt/alt/python37/lib64/python3.7/json/__pycache__/ |
Current File : //opt/alt/python37/lib64/python3.7/json/__pycache__/tool.cpython-37.opt-1.pyc |
B � f% � @ sj d Z ddlZddlZddlZdd� Zedkrfy e� W n. ek rd Z ze�ej � W ddZ[X Y nX dS )a Command-line tool to validate and pretty-print JSON Usage:: $ echo '{"json":"obj"}' | python -m json.tool { "json": "obj" } $ echo '{ 1.2:3.4}' | python -m json.tool Expecting property name enclosed in double quotes: line 1 column 3 (char 2) � Nc C s� d} d}t j| |d�}|jddt jdd�dd � |jd dt jddd�dd � |jd dddd� |�� }|jpptj}|jp|tj }|j }|�@ yt�|�}W n* t k r� } zt|��W d d }~X Y nX W d Q R X |�" tj|||dd� |�d� W d Q R X d S )Nzpython -m json.toolzZA simple command line interface for json module to validate and pretty-print JSON objects.)�prog�description�infile�?zutf-8)�encodingz-a JSON file to be validated or pretty-printed)�nargs�type�help�outfile�wz%write the output of infile to outfilez--sort-keys� store_trueFz5sort the output of dictionaries alphabetically by key)�action�defaultr � )� sort_keys�indent� )�argparse�ArgumentParser�add_argumentZFileType� parse_argsr �sys�stdinr �stdoutr �json�load� ValueError� SystemExit�dump�write) r r �parserZoptionsr r r �obj�e� r# �./opt/alt/python37/lib64/python3.7/json/tool.py�main s* $r% �__main__) �__doc__r r r r% �__name__�BrokenPipeError�exc�exit�errnor# r# r# r$ �<module> s