Your IP : 216.73.216.60


Current Path : /opt/alt/python37/lib/python3.7/site-packages/pylint/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/pylint/__pycache__/lint.cpython-37.opt-1.pyc

B

AWv\z�@s�dZddlmZddlZddlZddlZddlZyddlZWnek
rTdZYnXddl	Z	ddl
Z
ddlZddlZddl
mZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZddlmZejZd
d�Zdd�Zdd�Zdddddddddddddd gifd!d"d#d$�
Z e!d%�d&d'�Z"edk	�rdGd(d)�d)ej#�Z$Gd*d+�d+ej%ej&ej'ej(�Z)d,d-�Z*d.d/�Z+d0d1�Z,Gd2d3�d3e-�Z.d4d5�Z/ej0d6d7��Z1Gd8d9�d9�Z2d:d;�Z3d<d=�Z4e5d>k�r�e2e	j6d?d��dS)@a %prog [options] modules_or_packages

  Check that module(s) satisfy a coding standard (and more !).

    %prog --help

  Display this help message and exit.

    %prog --help-msg <msg-id>[,<msg-id>]

  Display help messages about given message identifiers and exit.
�)�print_functionN)�version)�modutils)�checkers)�
interfaces)�	reporters)�
exceptions)�utils)�config)�nodescCs2|j|j|j|j|j|jf}|j|j||j|j	fS)N)
�abspath�path�module�obj�line�column�msg_idZsymbol�msg�
confidence)�message�location�r�</opt/alt/python37/lib/python3.7/site-packages/pylint/lint.py�
_get_new_args\srcCsptj�tj�|��}tj�|�s,tj�|�}x>tj�tj�|d��sH|S|}tj�|�}||kr.t��Sq.WdS)Nz__init__.py)	�osr
�realpath�
expanduser�isdir�dirname�exists�join�getcwd)�filepathrZold_dirnamerrr�_get_python_pathhsr#cCs�i}t��}xt|D]l}|�di�}|�|�xP|��D]D\}}||krP|||<q6t|t�rj||�|�q6|||||<q6WqW||d<|S)N�by_msg)�collections�Counter�pop�update�items�
isinstance�dict)�statsZmergedr$�statZ
message_stats�key�itemrrr�_merge_statsvs



r0)z%s�fatalzoUsed when an error occurred preventing the analysis of a               module (unable to find it for instance).)z%s: %sz
astroid-errorz�Used when an unexpected error occurred while building the Astroid  representation. This is usually accompanied by a traceback. Please report such errors !)zerror while code parsing: %szparse-errorzlUsed when an exception occurred while building the Astroid representation which could be handled by astroid.)z0Unable to run raw checkers on built-in module %szraw-checker-failedzRUsed to inform that a built-in module has not been checked using the raw checkers.)z#Unable to consider inline option %rzbad-inline-optionzUUsed when an inline option is either badly formatted or can't be used inside modules.)zLocally disabling %s (%s)zlocally-disabledzEUsed when an inline option disables a message or a messages category.)zIgnoring entire filezfile-ignoredz0Used to inform that the file will not be checked)zSuppressed %s (from line %d)zsuppressed-messagez�A message was triggered on a line, but suppressed explicitly by a disable= comment in the file. This message is not generated for messages that are ignored due to configuration settings.)zUseless suppression of %szuseless-suppressionzbReported when a message is explicitly disabled for a line or a block of code, but never triggered.z+Pragma "%s" is deprecated, use "%s" insteadzdeprecated-pragmaz�Some inline pylint options have been renamed or reworked, only the most recent form should be used. NOTE:skip-all is only available with pylint >= 0.26Z	old_names)ZI0014zdeprecated-disable-all)z%szsyntax-errorz0Used when a syntax error is raised for a module.)zUnrecognized file option %rzunrecognized-inline-optionz2Used when an unknown inline option is encountered.)zBad option value %rzbad-option-valuez:Used when a bad value for an inline option is encountered.)
ZF0001ZF0002ZF0010ZI0001ZI0010ZI0011ZI0013ZI0020ZI0021ZI0022ZE0001ZE0011ZE0012)�returncCs,ttdd�}|rt|d��Str(t��SdS)zNUse sched_affinity if available for virtualized or containerized environments.�sched_getaffinityNr�)�getattrr�len�multiprocessing�	cpu_count)r3rrr�
_cpu_count�sr9c@seZdZdd�Zdd�ZdS)�ChildLintercCs�|j\}}|_d|jd<|j�dd�|_|j�dd�|_x~t|jd�D]n}y|�|d�}|�|�WqFt	k
r�}z.t
d|tjd�t
|tjd�|�i�Wdd}~XYqFXqFWdS)	Nr4�jobs�python3_porting_mode�plugins�STOPrz0internal error with sending report for module %s)�file)
�_args�_configr'�_python3_porting_mode�_plugins�iter�get�_run_linter�put�	Exception�print�sys�stderr)�self�tasks_queue�
results_queue�file_or_module�result�exrrr�run�s

zChildLinter.runcCs�t�}|��|jr |�|j�|�|j�|��|�t�	��|j
rP|��|�|�dd�|j
jD�}||jj|j||j|jfS)NcSsg|]}t|��qSr)r)�.0�mrrr�
<listcomp>sz+ChildLinter._run_linter.<locals>.<listcomp>)�PyLinter�load_default_pluginsrC�load_plugin_modulesZload_configuration_from_configrA�load_plugin_configuration�set_reporterrZCollectingReporterrBr<�check�reporter�messages�
file_state�	base_name�current_namer,�
msg_status)rLrO�linter�msgsrrrrF�s"
zChildLinter._run_linterN)�__name__�
__module__�__qualname__rRrFrrrrr:�sr:csLeZdZdZejfZdZdZdZ	e
Zedd��Z
dZdJ�fd	d
�	Zdd�Zd
d�Zdd�Zdd�Zdd�Zdd�ZdKdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Z d-d.�Z!edLd0d1��Z"d2d3�Z#d4d5�Z$d6d7�Z%d8d9�Z&d:d;�Z'd<d=�Z(dMd>d?�Z)d@dA�Z*dBdC�Z+dDdE�Z,dFdG�Z-dHdI�Z.�Z/S)NrValint Python modules using external checkers.

    This is the main checker controlling the other ones and the reports
    generation. It is itself both a raw checker and an astroid checker in order
    to:
    * handle message activation / deactivation at the module level
    * handle some basic but necessary stats'data (number of classes, methods...)

    IDE plugin developers: you may have to call
    `astroid.builder.MANAGER.astroid_cache.clear()` across runs if you want
    to ensure the latest code version is actually checked.
    �masterrcCshddddddd�fdd	d
ddd
d�fddddddd�fddddddd�fdddddddd �fd!d"ddd#dd$d �fd%dd&ddd'd(d)�fd*dddd+dd,d �fd-d.d/d0d1d2�tjD�d3d4d5�d6d7�tjD��fd8�fd9dd:d;d3d<d=�fd>dd:d?d3d@d=�fdAddBddCdD�fdEdFdGdHddIdJ�fdKddLd"ddMdN�fdOdFdPdQdRdS�fdTddUgdVdS�fdWddLddXdS�fdYdZd[d\�ffS)]N�ignoreZcsvz<file>[,<file>...]�
black_list)ZCVSzPAdd files or directories to the blacklist. They should be base names, not paths.)�type�metavar�dest�default�helpzignore-patternsZ
regexp_csvz<pattern>[,<pattern>...]�
black_list_rerzwAdd files or directories matching the regex patterns to the blacklist. The regex matches against base names, not paths.�
persistentTZynz<y_or_n>r4z,Pickle collected data for later comparisons.)rmrjrk�levelrnzload-pluginsz	<modules>zuList of plugins (as comma separated values of python modules names) to load, usually to register additional checkers.)rjrkrmrqrnz
output-format�text�stringz<format>�f�Reportsz�Set the output format. Available formats are text, parseable, colorized, json and msvs (visual studio). You can also give a reporter class, e.g. mypackage.mymodule.MyReporterClass.)rmrjrk�short�grouprn�reportsF�rz<Tells whether to display a full report or only the messages.�
evaluationz<python_expression>zN10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)a6Python expression which should return a note less than 10 (10 is the highest note). You have access to the variables errors warning, statement which respectively contain the number of errors / warnings messages and the total number of statements analyzed. This is used by the global evaluation report (RP0004).)rjrkrwrqrmrn�score�szActivate the evaluation score.rZmultiple_choicez<levels>�cSsg|]
}|j�qSr)�name)rS�crrrrU�sz)PyLinter.make_options.<locals>.<listcomp>zMessages controlz`Only show warnings with the listed confidence levels. Leave empty to show all. Valid levels: %s.z, css|]}|jVqdS)N)r~)rSrrrr�	<genexpr>�sz(PyLinter.make_options.<locals>.<genexpr>)rjrkrm�choicesrwrn�enablez	<msg ids>�ea/Enable the message, report, category or checker with the given id(s). You can either give multiple identifier separated by comma (,) or put this option multiple time (only on the command line, not in the configuration file where it should appear only once). See also the "--disable" option for examples.)rjrkrvrwrn�disable�dacDisable the message, report, category or checker with the given id(s). You can either give multiple identifiers separated by comma (,) or put this option multiple times (only on the command line, not in the configuration file where it should appear only once). You can also use "--disable=all" to disable everything first and then reenable specific checks. For example, if you want to run only the similarities checker, you can use "--disable=all --enable=similarities". If you want to run only the classes checker, but have no Warning level messages displayed, use "--disable=all --enable=classes --disable=W".zmsg-templatez
<template>z�Template used to display messages. This is a python new-style format string used to format the message information. See doc for all details.)rjrkrwrnr;�intz
<n-processes>�jzsUse multiple processes to speed up Pylint. Specifying 0 will auto-detect the number of processors available to use.)rjrkrvrmrnzunsafe-load-any-extensionz<yn>zAllow loading of arbitrary C extensions. Extensions are imported into the active Python interpreter and may run arbitrary code.)rjrkrm�hidernzlimit-inference-resultsz<number-of-results>�dz�Control the amount of potential inferred values when inferring a single object. This can help the performance when dealing with large functions or complex, nested conditions. )rjrkrmrnzextension-pkg-whitelistz<pkg[,pkg]>z�A comma-separated list of package or module names from where C extensions may be loaded. Extensions are loading into the active Python interpreter and may run arbitrary code.zsuggestion-modez�When enabled, pylint would attempt to guess common misconfiguration and emit user-friendly hints instead of false-positive error messages.z	exit-zero�
store_truez�Always return a 0 (non-error) status code, even if lint errors are found. This is primarily useful in continuous integration scripts.)�actionrn)r�CONFIDENCE_LEVELSr rrrr�make_options>s�
	zPyLinter.make_options))zMessages controlz%Options controlling analysis messages)ruz2Options related to output formatting and reportingrNcs8t��|_d|_d|_i|_t�t�|_	i|_
d|_t��|_
d|_d|_d|_||_|t��|_|tj|_|j|jd�|_|j|jd�|_dtttjf}tj�|�tj�|�t t|�jt!||p�t"j#d�t$j%�|�ddt&fdd	t'fd
dt(ff|_)|�*|�t+�|_,d|_-d|_.|�/�|�r4|�0|�dS)NF)r�r�)zdisable-msgz
enable-msgz%%prog %s
astroid %s
Python %s)ZusagerZconfig_fileZRP0001zMessages by categoryZRP0002z% errors / warnings by moduleZRP0003ZMessages)1r	Z
MessagesStore�
msgs_storer\�_reporter_name�
_reportersr%�defaultdict�list�	_checkers�_pragma_lineno�_ignore_file�	FileStater^r`�current_filer,�_external_optsrVr��options�
option_groupsr�r��_options_methods�_bw_options_methodsr�astroid_versionrJ�MessagesHandlerMixIn�__init__�ReportsHandlerMixIn�super�__doc__r
ZPYLINTRCr�BaseTokenChecker�report_total_messages_stats�report_messages_by_module_stats�report_messages_statsrx�register_checker�set�_dynamic_pluginsrB�_error_modeZload_provider_defaultsrZ)rLr�r\r��pylintrcZfull_version)�	__class__rrr�6sL




zPyLinter.__init__cCs&t�|�t�|�|js"|��dS)N)rZ
initializerr\�_load_reporter)rLrrrrWls

zPyLinter.load_default_pluginscCs>x8|D]0}||jkrq|j�|�t�|�}|�|�qWdS)z`take a list of module names which are pylint plugins and load
        and register them
        N)r��addr�load_module_from_name�register)rL�modnames�modnamerrrrrXts


zPyLinter.load_plugin_modulescCs2x,|jD]"}t�|�}t|d�r|�|�qWdS)z�Call the configuration hook for plugins

        This walks through the list of plugins, grabs the "load_configuration"
        hook, if exposed, and calls it to allow plugins to configure specific
        settings.
        �load_configurationN)r�rr��hasattrr�)rLr�rrrrrYs

z"PyLinter.load_plugin_configurationc	Csh|j��}||jkr(|�|j|��n<y|��}Wn"ttfk
rVt�|��YnX|�|��dS)N)	r��lowerr�rZ�_load_reporter_class�ImportError�AttributeErrorrZInvalidReporterError)rLr~�reporter_classrrrr��s

zPyLinter._load_reportercCs2|j}t�t�|��}|�d�d}t||�}|S)N�.���)r�rr�Zget_module_part�splitr5)rLZqnamer�
class_namer�rrrr��s

zPyLinter._load_reporter_classcCs||_||_dS)z5set the reporter used to display messages and reportsN)r\rb)rLr\rrrrZ�szPyLinter.set_reporterc
Cs
||jks||jkr�|r�y|j|}Wn<tk
rb|j|}t�d||�d�dft�YnXt�|�}t	|t
tf�r�x"|D]}||dd�q�Wn||�dSn|dkr�||_|j
r�|��ytj�|||||�Wn*tjk
�rtd|tjd	�YnXdS)
z[overridden from config.OptionsProviderMixin to handle some
        special options
        z"%s is deprecated, replace it by %s�-rT)Zignore_unknownNz
output-formatz(option %s can't be read from config file)r?)r�r��KeyError�warnings�warnr��DeprecationWarningr	Z
_check_csvr*r��tupler�r�r�rr��
set_optionr
ZUnsupportedActionrIrJrK)rL�optname�valuer��optdict�methZ_idrrrr��s0


zPyLinter.set_optioncCs||j|j<dS)N)r�r~)rLr�rrr�register_reporter�szPyLinter.register_reportercCsJt|jdd�d�}y|�|�|��Wntk
r:YnX|�|�|S)NcSst|dd�S)Nr~r})r5)�xrrr�<lambda>��z'PyLinter.report_order.<locals>.<lambda>)r.)�sorted�_reportsr'�index�
ValueError�append)rLrxrrr�report_order�s
zPyLinter.report_ordercCs�|jdkstd��|j|j�|�x$|jD]\}}}|�||||�q,W|�|�t|d�rj|j	�
|�|��t|dd�s�|�
|j�dS)zoregister a new checker

        checker is an object implementing IRawChecker or / and IAstroidChecker
        rzchecker priority can't be >= 0rcZenabledTN)�priority�AssertionErrorr�r~r�rxZregister_reportZregister_options_providerr�r�Zregister_messages_from_checkerZ
load_defaultsr5r�)rL�checkerZr_idZr_titleZr_cbrrrr��s

zPyLinter.register_checkercCsXxR|jj��D]B\}}|dkr8x0|D]}|�|�q$Wqx|D]}|�|�q>WqWdS)N)�E�F)r�Z_msgs_by_categoryr)r�r�)rLZmsgcatZmsgids�msgidrrr�disable_noerror_messages�s

z!PyLinter.disable_noerror_messagescCs6x0|j��D]"}x|D]\}}}|�|�qWqWdS)zdisable all reportersN)r��valuesZdisable_report)rLr�Z	report_id�_rrr�disable_reporters�szPyLinter.disable_reporterscCs�d|_|��|�d�|jr||�d�x&|�d�D]}|�d�r4|�|�q4W|j}|�dd�r�|�	dd�}|�
d|�n
|�d�|�dd	�|�d
d	�|�dd	�dS)
z9error mode: enable only errors; no reports, no persistentTZ
miscellaneous�all�python3r�zMESSAGES CONTROLr�rxFrpr{N)r�r�r�rB�_checker_messages�
startswithr��cfgfile_parser�
has_optionrE�global_set_optionr�)rLr�
config_parserr�rrr�
error_mode�s 



zPyLinter.error_modecCs�|�d�|�d�|jrNx2|�d�D]$}|�d�r@|�|�q&|�|�q&W|j}|�dd�rx|�dd�}|�d|�d|_	dS)z8Disable all other checkers and enable Python 3 warnings.r�r�r�zMESSAGES CONTROLr�TN)
r�r�r�r�r�r�r�rEr�rB)rLrr�r�rrrr<
s


zPyLinter.python3_porting_modec
Cs ddh}�x|D�]\}}}}}|tjkr,qtj�|�}|dkrBq|�d�}|��dksd|��dkr�|��dkr�|jd|dd	d
�|jd|dd�d
|_dSy|�	dd�\}	}
Wn.t
k
r�|jd|��|dd�wYnX|	��}	|	|jk�s|	|jk�ry|j|	}Wn@t
k
�rR|j|	}|jd|d|	|	�dd�fd
�YnXx�t�|
�D]�}|	|k�r||d|j|<yR|	|fdk�r�|jd|ddd
�|jd|dd�d
|_dS||d|d�Wn,tjk
�r�|jd||dd�YnX�q`Wq|jd|	|dd�qWdS)z`process tokens from the current module to search for module/block
        level options
        r�r�Nr4zdisable-allz	skip-filezdeprecated-pragmar)zdisable-allz	skip-file)r�argszfile-ignored)rT�=zbad-inline-option)r�rz-msgr})r�r�)zdisable=allz	skip-filerzbad-option-valuezunrecognized-inline-option)�tokenize�COMMENTr	Z
OPTION_RGX�searchrw�strip�add_messager�r�r�r�r�r��replace�_splitstripr�rZUnknownMessageError)
rL�tokensZcontrol_pragmas�tok_typeZcontent�startr��matchZfirst_group�optr�r�r�rrr�process_tokens$sd



"zPyLinter.process_tokenscs�g�fdd��j��D�S)z'return all available checkers as a listcs"g|]}|D]}|�k	r|�qqSrr)rSr�r)rLrrrUksz)PyLinter.get_checkers.<locals>.<listcomp>)r�r�)rLr)rLr�get_checkershs
zPyLinter.get_checkerscCs|��}tdd�|D��S)z7Get all the checker names that this linter knows about.cSsh|]}|jdkr|j�qS)rg)r~)rSr[rrr�	<setcomp>usz-PyLinter.get_checker_names.<locals>.<setcomp>)r�r�)rLZcurrent_checkersrrr�get_checker_namesqszPyLinter.get_checker_namescs��jjs����g}xR���dd�D]>}�fdd�|jD�}|s\t�fdd�|jD��r(|�|�q(Wt|t�	d�dd	�}|S)
z9return checkers needed for activated messages and reportsr4Ncsh|]}��|�r|�qSr)Zis_message_enabled)rSr)rLrrr�sz,PyLinter.prepare_checkers.<locals>.<setcomp>c3s|]}��|d�VqdS)rN)Zreport_is_enabled)rSry)rLrrr��sz,PyLinter.prepare_checkers.<locals>.<genexpr>r�T)r.�reverse)
r
rxr�r�rc�anyr�r��operator�
attrgetter)rLZneededcheckersr�r]r)rLr�prepare_checkersxszPyLinter.prepare_checkersFcCs|rdS|�d�S)aReturns whether or not a module should be checked.

        This implementation returns True for all python source file, indicating
        that all files should be linted.

        Subclasses may override this method to indicate that modules satisfying
        certain conditions should not be linted.

        :param str modname: The name of the module to be checked.
        :param str path: The full path to the source code of the module.
        :param bool is_argument: Whetter the file is an argument to pylint or not.
                                 Files which respect this property are always
                                 checked, since the user requested it explicitly.
        :returns: True if the module should be checked.
        :rtype: bool
        Tz.py)�endswith)r�r
�is_argumentrrr�should_analyze_file�szPyLinter.should_analyze_filecCs`x$|jjD]}|��s
d|j|j<q
Wt|ttf�s:|f}|jj	dkrR|�
|�n
|�|�dS)zWmain checking entry: check a list of files or modules from their
        name.
        Fr4N)r�r]Zmay_be_emittedZ_msgs_stater�r*r�r�r
r;�	_do_check�_parallel_check)rL�files_or_modulesrrrrr[�szPyLinter.checkcCs�t��}dh}|�dd�|jD��xN|j��D]@}x:|��D].\}}}|�d�rTq>||kr>t�	||�||<q>Wq0W|j
|d<|j|d<|S)Nz	long-helpcss|]\}}|VqdS)Nr)rSZopt_namer�rrrr��sz,PyLinter._get_jobs_config.<locals>.<genexpr>Z
deprecatedr<r=)r%�OrderedDictr(r�Z_all_optionsr�Zoptions_and_valuesrEr	Z_format_option_valuerBr�)rL�child_configZfilter_optionsZ
opt_providersr�r��valrrr�_get_jobs_config�s


zPyLinter._get_jobs_configccs�|��}g}t��}|��}|��}g}xH|�|�D]:}|d|d|d}	}
}|j|	|
|d�r4|�|�q4Wx@tt|j	j
t|���D]&}t|||fd�}
|
�
�|�|
�q�Wx |D]}|d}|�|g�q�Wd}xf|D]^}y|��}WnFtk
�r6}z&tdtjd�t|tjd�d	}PWdd}~XYnX|Vq�Wx t|j	j
�D]}|�d
��qPWx|D]}|���qjW|�r�tdtjd�t�d�dS)
Nr~r
�isarg)r�)r�Fz8internal error while receiving results from child linter)r?Tr>z$Error occurred, stopping the linter.� )rr7ZManagerZQueue�expand_filesr�r��range�minr
r;r6r:r�rGrErHrIrJrKr �exit)rLrr�childrenZmanagerrMrNZexpanded_files�descrr�r"�is_argr�Zchild_linterZfiles_or_moduler
ZfailedrPrQZchildrrr�_parallel_task�sH




zPyLinter._parallel_taskcCs�|��g}d}xr|�|�D]d}|s&q|\}|j_}}}}x,|D]$}	tj|	�}	|�|�|j�|	�q@W|�	|�|j
|O_
qWt|�|_||_
x |��D]}
|
|k	r�|j|
_q�WdS)N)�openrr^r_r	ZMessage�set_current_moduler\Zhandle_messager�rar0r,r`r�)rLrZ	all_statsrrPr�r]r,rarr�rrrr�s$




zPyLinter._parallel_checkcsRt���}���}�fdd�|D�}dd�|D�}x,|D]$}|��t�|tj�r8|�|�q8WxĈ�|�D]�}|d|d|d}}	}
�j	||	|
d�s�ql��
||	���|	|�}|dkr�qlt�|d��_
d	�_|j�_��||||��j
��j�}x$|D]\}
}}��|
|d|��qWqlW|j�jd
<xt|�D]}|���q<WdS)Ncs&g|]}t�|tj�r|�k	r|�qSr)r�
implements�
ITokenChecker)rSr)rLrrrUsz&PyLinter._do_check.<locals>.<listcomp>cSsg|]}t�|tj�r|�qSr)rrZIRawChecker)rSrrrrrUsr~r
r)r��basenameF�	statement)r	ZPyLintASTWalkerr�rrrZIAstroidCheckerZadd_checkerr	r�r�get_astr�r^r�r?r��check_astroid_moduleZ"iter_spurious_suppression_messagesr�r�Znbstatementsr,�reversed�close)rLr�walkerr��
tokencheckers�rawcheckersr�rr�r"r�ast_nodeZspurious_messagesr�rr�r)rLrrs8


zPyLinter._do_checkcCs~t�||jj|jj�\}}x^|D]V}|d}}|d}|�|�|dkrht|d��t�	�tj
d�}|j||d�q W|S)zHget modules and errors from a list of modules and handle errors
        �modr.r1rQr})r�)r	Zexpand_modulesr
riror�strr�rr!�sepr�)rL�modulesrP�errors�errorrr�r.rrrr	?s

zPyLinter.expand_filescCsx|s|dkrdS|j�||�||_|p*||_i|jd|<d|jd|d<x$tj��D]}d|jd||<qZWdS)zYset the name of the currently analyzed module and
        init statistics for it
        N�	by_modulerr)r\Zon_set_current_moduler`r�r,r	�	MSG_TYPESr�)rLr�r"�msg_catrrrrNs
zPyLinter.set_current_modulec
Cs�ytj||dd�Stjk
rT}z$|jdt|jdd�t|j�d�Wdd}~XYnvtjk
r�}z|jd|d	�Wdd}~XYnFt	k
r�}z(ddl
}|��|jd
|j|fd	�Wdd}~XYnXdS)z/return an ast(roid) representation for a moduleT)�sourcezsyntax-error�linenor)rr�Nzparse-error)r�z
astroid-error)
�MANAGERZ
ast_from_file�astroidZAstroidSyntaxErrorr�r5r$r ZAstroidBuildingExceptionrH�	traceback�	print_excr�)rLr"r�rQr,rrrr\s,zPyLinter.get_astc
Cs�yt�|�}WnDtjk
rR}z$|jd|jdd|jdd�dSd}~XYnX|jsl|jd|jd�nT|�|�|j	r�dS|j
�|j|�x|D]}|�
|�q�Wx|D]}|�|�q�W|�|�d	S)
z/Check a module from its astroid representation.zsyntax-errorr4r)rr�Nzraw-checker-failed)r�FT)r	Ztokenize_moduler��
TokenErrorr�r�Zpure_pythonr~r�r�r^Zcollect_block_linesr�Zprocess_module�walk)rLrrrrr�rQr�rrrrms" 



zPyLinter.check_astroid_modulecCsRiid�|_|jjt_|jjt_tj�|jj	�xt
j��D]}d|j|<q<WdS)zinitialize counters)r%r$rN)
r,r
Zunsafe_load_any_extensionr*Zalways_load_extensionsZlimit_inference_resultsZmax_inferable_valuesZextension_package_whitelistr(Zextension_pkg_whitelistr	r&r�)rLr'rrrr�s

z
PyLinter.opencCs�|j�t���|jjdk	r�t�|jj�}|j�|j	|�|jj
rR|�|j	|�}nt��}|jj
rn|j�|�|�
�|jjr�t�|j	|jj�n|j�|j	i�dS)z�close the whole package /module, it's time to make reports !

        if persistent run, pickle results for later comparison
        N)r\Zdisplay_messages�report_nodesZSectionr^r_r
�load_resultsZon_closer,rxZmake_reports�display_reports�_report_evaluationrpZsave_results)rL�previous_stats�sectrrr�generate_reports�szPyLinter.generate_reportsc
Cs�t�|jj�}|jddkr dS|jj}yt|i|j�}Wn*tk
rd}zd|}Wdd}~XYn:X||jd<d|}|�d�}|dk	r�|d|||f7}|jj	r�t
�|�}|j�
|�dS)z!make the global evaluation reportrrNz&An exception occurred while rating: %sZglobal_notez#Your code has been rated at %.2f/10z (previous run: %.2f/10, %+.2f))r
r1r^r_r,rz�evalrHrEr{r0ZEvaluationSectionr\r2)rLr4rzZnoterQrZpnoter5rrrr3�s 


zPyLinter._report_evaluation)rNrN)NN)F)N)0rdrerfr�rrZ__implements__r~r�rq�MSGSrc�staticmethodr�r�r�rWrXrYr�r�rZr�r�r�r�r�r�r�r<r�r�r�r�r�r[rrrrr	rrrrr6r3�
__classcell__rr)r�rrV$sTu6
"
D	3/
	rVcCs8ddddg}|t�||d�7}|�tj|ddd��d	S)
z#make total errors / warnings reportrjZnumberZprevious�
difference)�
convention�refactor�warningr$�r4)r
�cols�rheadersN)rZtable_lines_from_statsr�r0�Table)r5r,r4�linesrrrr��sr�cCsr|dst���tdd�|d��D��}|��d}x |D]\}}||t|�f7}q<W|�tj|ddd��dS)	zmake messages type reportr$cSs"g|]\}}|�d�s||f�qS)�I)r�)rSrr�rrrrU�sz)report_messages_stats.<locals>.<listcomp>)z
message idZoccurrences�r4)r
r@rAN)	r�EmptyReportErrorr�r)r�r r�r0rB)r5r,r�Zin_orderrCr�rrrrr��sr�cCstt|d�dkrt���t�t�}xddD]\}||}xN|d��D]>}|d||}|dkrdd}nt|d�|}||||<qBWq(Wg}	x8|��D],\}}
|	�	|
d|
d|
d|
d	|f�q�W|	�
�|	��d
dddd	g}x^|	D]V}tdd�|d
d�D���rq�|�	|d�x$|d
d�D]}
|�	d|
��q(Wq�Wt|�dk�rZt���|�	t
j|ddd��d
S)z(make errors / warnings by modules reportr%r4)r1r$r>r=r<rr�r$r>r=r<rcss|]}|dkVqdS)rNr)rS�entryrrrr�sz2report_messages_by_module_stats.<locals>.<genexpr>Nr�z%.2f�)r
r@rA)r6rrFr%r�r+�keys�floatr)r��sortr�r�r0rB)r5r,r�Zby_modZm_typeZtotalrZ	mod_totalZpercentZ
sorted_resultZmod_inforCrrrrrr��s>


r�c@seZdZdZdS)�ArgumentPreprocessingErrorz8Raised if an error occurs during argument preprocessing.N)rdrerfr�rrrrrLsrLc	Cs$d}�x|t|�k�r||}|�d��ry|dd��dd�\}}Wn&tk
rl|dd�d}}YnXy||\}}Wntk
r�|d7}YnxX||=|r�|dkr�|t|�ks�||�d�r�d|}t|��||}||=n |�s|dk	�rd	|}t|��|||�q|d7}qWdS)
z�look for some options (keys of <search_for>) which have to be processed
    before others

    values of <search_for> are callback functions to call when the option is
    found
    rz--rENr�r4r�zOption %s expects a valuez!Option %s doesn't expects a value)r6r�r�r�r�rL)	r�Z
search_for�i�arg�optionr�cbZtakeargrrrr�preprocess_optionss0rQc
cstttj�}g}x*|D]"}t|�}||kr,qq|�|�qW|dgtjtjdd�<z
dVWd|tjdd�<XdS)aBPrepare sys.path for running the linter checks.

    Within this context, each of the given arguments is importable.
    Paths are added to sys.path in corresponding order to the arguments.
    We avoid adding duplicate directories to sys.path.
    `sys.path` is reset to its original value upon exiting this context.
    r�N)r�rJr
r#r�)r�ZorigZchangesrNr
rrr�fix_import_path;s	


rRc@szeZdZdZeZdZddd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�ZdS)�RunzEhelper class to use as main for pylint :

    run(*sys.argv[1:])
    ))�CommandszROptions which are actually commands. Options in this group are mutually exclusive.NTc	Cs�d|_g|_d|_y.t|tdf|jdf|jdf|jdfd��Wn:tk
rz}zt	|t
jd�t
�d�Wdd}~XYnX|j
dddd	�d
ddd
�fdddd	�d
dddd�fddd
d|jddd�fddd|jdddd�fddd|jdddd�fddtdddd �fd!dd|jddd"d�fd#d|jdd$d%�fd&d|jdd'dd(�fd)d|jd*d+d,�fd-d|jd.d/�fd0d|jd1d2d,�ff|j|jd3�|_}|��|�|j�|jd4tjdd5�|jd6d7dd5�|jd8d9dd5�|�d:�|�d;�|j |jd<�|j!}|�"d=d��rtdt#�$|�%d=d���|�"d=d>��rFt#�&|�%d=d>��}|�|�|�'�|�r^|�(|�y|�)|�}Wn8t*k
�r�}z|j+d?k�r�d|_+�Wdd}~XYnX|�s�t	|�,��t
�d�|jj-d@k�r�t	dA|jj-t
jd�t
�d�|jj-dk�s|jj-d@k�rJt.dk�r2t	dBt
jd�|�/dCd�n|jj-d@k�rJt0�|j_-|�1�t2|��|�3|�|�4�WdQRX|�r�|jj5�r�t
�d@�nt
�|jj6�dS)DNTF)z	init-hook�rcfilezload-plugins�verbose)r?rrU�callbackcWsdS)Nr4r)r�rrrr�{r�zRun.__init__.<locals>.<lambda>rsz<file>zSpecify a configuration file.)r�rWrjrkrnz	init-hookcWsdS)Nr4r)r�rrrr��r�z<code>r4zRPython code to execute, usually for sys.path manipulation such as pygtk.require().)r�rWrjrkrqrnzhelp-msgz<msg-id>rTzqDisplay a help message for the given message id and exit. The value may be a comma separated list of message ids.)r�rjrkrWrwrnz	list-msgszGenerate pylint's messages.)r�rkrWrwrqrnzlist-groupszList pylint's message groups.zlist-conf-levelsz$Generate pylint's confidence levels.)r�rWrwrqrnzfull-documentationz%Generate pylint's full documentation.zgenerate-rcfilez�Generate a sample configuration file according to the current configuration. You can put other options before this one to get them in the generated configuration.)r�rWrwrnzgenerate-manzGenerate pylint's man page.)r�rWrwrnr�zerrors-onlyr�z�In error mode, checkers without error messages are disabled and for others, only the ERROR messages are displayed, and no reports are done by default.)r�rWrvrnZpy3kz{In Python 3 porting mode, all checkers will be disabled and only messages emitted by the porting checker will be displayed.)r�rWrnrV�vzBIn verbose mode, extra non-checker-related info will be displayed.)r�r�zEnvironment variables)rqZOutputa5Using the default text output, the message format is :                          
                                                                                
        MESSAGE_TYPE: LINE_NUM:[OBJECT:] MESSAGE                                
                                                                                
There are 5 kind of message types :                                             
    * (C) convention, for programming standard violation                        
    * (R) refactor, for bad code smell                                          
    * (W) warning, for python specific problems                                 
    * (E) error, for probable bugs in the code                                  
    * (F) fatal, if an error occurred which prevented pylint from doing further
processing.
zOutput status codea[Pylint should leave with following status code:                                 
    * 0 if everything went fine                                                 
    * 1 if a fatal message was issued                                           
    * 2 if an error message was issued                                          
    * 4 if a warning message was issued                                         
    * 8 if a refactor message was issued                                        
    * 16 if a convention message was issued                                     
    * 32 on usage error                                                         
                                                                                
status 1 to 16 will be bit-ORed so you can know which different categories has
been issued by analysing pylint output status code
rDzc-extension-no-member)rVZMASTERzload-pluginsrErz5Jobs number (%d) should be greater than or equal to 0z>Multiprocessing library is missing, fallback to single processr;)7�_rcfilerCrVrQ�cb_init_hook�
cb_set_rcfile�cb_add_plugins�cb_verbose_moderLrIrJrKr�LinterClass�cb_help_message�cb_list_messages�cb_list_groups�cb_list_confidence_levels�cb_full_documentation�cb_generate_config�cb_generate_manpage�
cb_error_mode�cb_python3_porting_moder�rbrWrXZadd_help_sectionr
ZENV_HELPr�r�Zread_config_filer�r�r	Z_unquoterEr�Zload_config_filerZZload_command_line_configuration�
SystemExit�codernr;r7r�r9rYrRr[r6Z	exit_zerora)	rLr�r\Zdo_exitrQrbr�r=�excrrrr�bs













zRun.__init__cCs
||_dS)z>callback for option preprocessing (i.e. before option parsing)N)rY)rLr~r�rrrr[dszRun.cb_set_rcfilecCs|j�t�|��dS)z>callback for option preprocessing (i.e. before option parsing)N)rC�extendr	r�)rLr~r�rrrr\hszRun.cb_add_pluginscOs|j��dS)z�error mode:
        * disable all but error messages
        * disable the 'miscellaneous' checker which can be safely deactivated in
          debug
        * disable reports
        * do not save execution information
        N)rbr�)rLr��kwargsrrrrflszRun.cb_error_modecOs|jjdd�t�d�dS)z0optik callback for sample config file generation)ZCOMMANDS)ZskipsectionsrN)rbZgenerate_configrJr)rLr�rlrrrrdvszRun.cb_generate_configcOs&ddlm}|j�|�t�d�dS)z0optik callback for sample config file generationr)�__pkginfo__N)�pylintrmrbZgenerate_manpagerJr)rLr�rlrmrrrre{szRun.cb_generate_manpagecCs"|jj�t�|��t�d�dS)z@optik callback for printing some help about a particular messagerN)rbr�Zhelp_messager	r�rJr)rLrOr�r��parserrrrr_�szRun.cb_help_messagecCs|j��t�d�dS)z.optik callback for printing full documentationrN)rbZprint_full_documentationrJr)rLrOr�r�rorrrrc�s
zRun.cb_full_documentationcCs|jj��t�d�dS)z.optik callback for printing available messagesrN)rbr�Z
list_messagesrJr)rLrOr�r�rorrrr`�szRun.cb_list_messagescOs*x|j��D]}t|�qWt�d�dS)z�List all the check groups that pylint knows about

        These should be useful to know what check groups someone can disable
        or enable.
        rN)rbr�rIrJr)rLr�rlr[rrrra�szRun.cb_list_groupscOs|j��dS)z*Activate only the python3 porting checker.N)rbr<)rLr�rlrrrrg�szRun.cb_python3_porting_modecOs
d|_dS)NT)rV)rLr�rlrrrr]�szRun.cb_verbose_mode)NT)rdrerfr�rVr^r�r�r[r\rfrdrer_rcr`rargr]rrrrrSSs"


rScCs*xtjD]}td|�qWt�d�dS)Nz	%-18s: %sr)rr�rIrJr)rOr�r�rorqrrrrb�srbcCst|�dS)z0exec arbitrary code to set sys.path for instanceN)�exec)r�r�rrrrZ�srZ�__main__r4)7r�Z
__future__rr%�
contextlibr�rr7r�rJr�r�r+Zastroid.__pkginfo__rr�rrnrrrrr	r
Zpylint.__pkginfo__Zpylint.reporters.ureportsrr0r*rr#r0r8r�r9ZProcessr:ZOptionsManagerMixInr�r�r�rVr�r�r�rHrLrQ�contextmanagerrRrSrbrZrd�argvrrrr�<module><s�


=
+	,#R