Mini Shell
U
��eg� � @ sX d dl Z d dlZd dlZd dlmZ d dlZd dlmZ dd� ZedkrTe � e� � dS )� N)�pformat)�
exceptionsc
C s� t �� } | �d� | jdddd� | jdddd � | �� }|j}|jrtt�|j�}tj �
t|j�� tj �
d
� dS |j
r�t|j
d��}t�|�}W 5 Q R X ntj�� }t�|�}z0tj �
tjt�||�d
dd�� tj �
d
� W n� tjk
�r } ztj�
d| � W Y �dS d }~X Y n� tjk
�rX } ztj�
d| � W Y �dS d }~X Y nv tjk
�r� } ztj�
d| � W Y �dS d }~X Y n< tjk
�r� } ztj�
d| � W Y �dS d }~X Y nX d S )N�
expressionz-fz
--filenamezaThe filename containing the input data. If a filename is not given then data is read from stdin.)�helpz--ast�
store_truez-Pretty print the AST, do not search the data.)�actionr �
r �r� F)�indent�ensure_asciizinvalid-arity: %s
� zinvalid-type: %s
zunknown-function: %s
zsyntax-error: %s
)�argparse�ArgumentParser�add_argument�
parse_argsr �ast�jmespath�compile�sys�stdout�writer �parsed�filename�open�json�load�stdin�read�loads�dumps�searchr Z
ArityError�stderrZJMESPathTypeErrorZUnknownFunctionErrorZ
ParseError)�parser�argsr �f�data�e� r( �</opt/cppython/lib/python3.8/site-packages/../../../bin/jp.py�main sN
��
�r* �__main__)
r r r �pprintr r r r* �__name__�exitr( r( r( r) �<module> s )
Zerion Mini Shell 1.0