B YI~d%� @sfddlZddlZddlZdd�Zedkrby e�Wn.ek r`Zze�ej�WddZ[XYnXdS)�Nc Cs�d}d}tj||d�}|jddtjdd�dd �|jd dtjd dd�d d �|jd dddd�|��}|jpptj}|jp|tj }|j }|�@yt � |�}Wn*t k r�}z t|��Wdd}~XYnXWdQRX|�"t j|||dd�|�d�WdQRXdS)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_argument�FileType� parse_argsr�sys�stdinr �stdoutr�json�load� ValueError� SystemExit�dump�write) rr�parser�optionsrr r�obj�e�r%�./opt/alt/python37/lib64/python3.7/json/tool.py�mains*   $r'�__main__) rrrr'�__name__�BrokenPipeError�exc�exit�errnor%r%r%r&�<module> s