B
    G[                 @   s`   d dl mZ d dlZd dlmZmZ d dlmZmZ d dl	m
Z
 d dlmZ G dd deZdS )	    )print_functionN)CondaPackageCheckCondaRecipeCheck)PackageErrorRecipeError)ensure_list)	getLoggerc               @   s,   e Zd ZdZedddZed	ddZdS )
VerifyzDVerify class is called by the CLI but may be used as an API as well.NFc          	   K   s   t | }d|kr|d s(d|kr6|d r6ttd g }xFt|D ]:}|drDt|| }|dk	rD|jt|krD|	| qDW |rt
d t
d xNt|D ]B}yt
|tjd W q tk
r   t
d	|jtjd Y qX qW |r|rt|dS )
zRun all package checks in order to verify a conda package.
        checks_to_ignore should be a list, tuple, or set of codes, such as ['C1102', 'C1104'].
        Codes are listed in readme.md.  Package codes follow 1xxx, recipe codes follow 2xxx.ignore_scriptsrun_scriptszIgnoring legacy ignore_scripts or run_scripts.  These have been replaced by the checks_to_ignore argument, which takes alist of codes, documented at https://github.com/conda/conda-verify#checkscheckNzPackage verification results:z-----------------------------)filez>Could not print message for error code {} due to unicode error)r   r   __name__warndir
startswithgetattrcoder   appendprintsortedsysstderrUnicodeEncodeErrorformatr   )Zpath_to_packagechecks_to_ignoreexit_on_errorkwZpackage_checkchecks_to_displaymethodr    r    2lib/python3.7/site-packages/conda_verify/verify.pyverify_package   s(    
 zVerify.verify_packagec       	   	   K   s   t | |}d|kr|d s*d|kr8|d r8ttd g }xFt|D ]:}|drFt|| }|dk	rF|jt|krF|	| qFW xRt
|D ]F}yt|tjd W q tk
r   tt|ddtjd Y qX qW |r|rt|dS )	zRun all recipe checks in order to verify a conda recipe.
        checks_to_ignore should be a list, tuple, or set of codes, such as ['C2102', 'C2104'].
        Codes are listed in readme.md.  Package codes follow 1xxx, recipe codes follow 2xxx.r
   r   zIgnoring legacy ignore_scripts or run_scripts.  These have been replaced by the checks_to_ignore argument, which takes alist of codes, documented at https://github.com/conda/conda-verify#checksr   N)r   zutf-8ignore)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   strencoder   )	Zrendered_metaZ
recipe_dirr   r   r   Zrecipe_checkr   r   r   r    r    r!   verify_recipe3   s"    

$zVerify.verify_recipe)NNF)NNNF)r   
__module____qualname____doc__staticmethodr"   r&   r    r    r    r!   r	      s   $ r	   )Z
__future__r   r   Zconda_verify.checksr   r   Zconda_verify.errorsr   r   Zconda_verify.utilitiesr   Zloggingr   objectr	   r    r    r    r!   <module>   s   