
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3
–Xf  ã               @   sÖ   d dl mZ d dlZd dlZd dlZd dlmZ d dlmZ dd„ Z	dd„ Z
ejd	d
�Zejdddde
dd� ejddddd� ejdde	dd� ejdde
d� dd„ Zejdd… fd d!„Zejejfd"d#„ZdS )$é    )Úabsolute_importN)ÚnamedAny)Úvalidator_forc             C   s   d| krd|  } t | ƒS )NÚ.zjsonschema.)r   )Úname© r   ú/usr/lib/python3.6/cli.pyÚ_namedAnyWithDefault
   s    r	   c          	   C   s   t | ƒ�}tj|ƒS Q R X d S )N)ÚopenÚjsonÚload)ÚpathÚfiler   r   r   Ú
_json_file   s    
r   zJSON Schema Validation CLI)Údescriptionz-iz
--instanceÚappendÚ	instancesz[a path to a JSON instance (i.e. filename.json)to validate (may be specified multiple times))ÚactionÚdestÚtypeÚhelpz-Fz--error-formatz"{error.instance}: {error.message}
z™the format to use for each error output message, specified in a form suitable for passing to str.format, which will be called with 'error' for each error)Údefaultr   z-Vz--validatorzŒthe fully qualified object name of a validator to use, or, for validators that are registered with jsonschema, simply the name of the class.)r   r   Úschemaz7the JSON Schema to validate with (i.e. filename.schema))r   r   c             C   s6   t tj| pdgd�ƒ}|d d kr2t|d ƒ|d< |S )Nz--help)ÚargsÚ	validatorr   )ÚvarsÚparserÚ
parse_argsr   )r   Ú	argumentsr   r   r   r   ;   s    r   é   c             C   s   t jtt| d�d�ƒ d S )N)r   )r   )ÚsysÚexitÚrunr   )r   r   r   r   ÚmainB   s    r#   c             C   sp   | d }| d | d d�}|j | d ƒ d}x>| d p8f D ].}x(|j|ƒD ]}|j|j|d�ƒ d}qJW q:W |S )	NÚerror_formatr   r   )r   Fr   )ÚerrorT)Zcheck_schemaZiter_errorsÚwriteÚformat)r   ÚstdoutÚstderrr$   r   ZerroredÚinstancer%   r   r   r   r"   F   s    r"   )Z
__future__r   Úargparser   r    Zjsonschema._reflectr   Zjsonschema.validatorsr   r	   r   ÚArgumentParserr   Úadd_argumentr   Úargvr#   r(   r)   r"   r   r   r   r   Ú<module>   s<   