o
    gG                     @   s   d dl Z d dlZd dlZd dlmZmZmZmZ d dlm	Z	 d dl
mZ d dlmZmZ d dlmZ zd dlZW n eyC   dZY nw defdd	Zd
d Zdd Zdd Ze ZG dd dZdS )    N)__pkginfo__config
extensions
interfaces)full_version)PyLinter)ArgumentPreprocessingErrorpreprocess_options)utilsreturnc                  C   s,   t tdd} | rt| dS trt S dS )zNUse sched_affinity if available for virtualized or containerized environments.sched_getaffinityNr      )getattroslenmultiprocessing	cpu_count)r    r   M/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/pylint/lint/run.py
_cpu_count   s   r   c                 C   sZ   t t jtjD ]}|dr%|ds%|d\}}}t	d|  q
t
d dS )z/List all the extensions under pylint.extensionsz.py_.zpylint.extensions.r   N)r   listdirpathdirnamer   __file__endswith
startswith	partitionprintsysexit)optionoptnamevalueparserfilenameextension_namer   r   r   r   cb_list_extensions   s   r(   c                 C   s(   t jD ]	}td|  qtd d S )Nz%-18s: r   )r   CONFIDENCE_LEVELSr   r    r!   )r"   r#   r$   r%   levelr   r   r   cb_list_confidence_levels)   s   
r+   c                 C   s   t | dS )z0exec arbitrary code to set sys.path for instanceN)exec)r#   r$   r   r   r   cb_init_hook/   s   r-   c                   @   s   e Zd ZdZeZdZedd Zdde	fddZ
d	d
 Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" ZdS )#RunzEhelper class to use as main for pylint :

    run(*sys.argv[1:])
    ))CommandszROptions which are actually commands. Options in this group are mutually exclusive.c                  G   s   dS )Nr   r   )argsr   r   r   _return_oneF   s   zRun._return_oneNTc                 C   s>  d | _ d | _d| _g | _d | _zt|| jdftdf| jdf| j	df| j
df| jdfd W n tyL } zt|tjd td W Y d }~nd }~ww | jddtjdd	d
ddfddtjdd	d
ddfddtjd	ddddfddd	d| jdddfddd| jddddfddd| jddddfddd| jddddfddtddd d!fd"dtddd#d!fd$dd| jddd%dfd&d| jdd'd(fd)d| jdd*dd+fd,d| jd-d.d/fd0d| j
d1d2d/ff| j| j d3 | _}| jrtt  td4 |!  |"| j |j#d5t$j%dd6 |j#d7d8dd6 |j#d9d:dd6 |&d; |'d< z	|j(| jd= W n t)yJ } zt|tjd td W Y d }~nd }~ww |j*}|+d>dratdt,-|.d>d |+d>d?rvt,/|.d>d?}|"| |0  |r|1| z|2|}W n t3y }	 z
|	j4d@krd|	_4 d }	~	ww |st|5  td |j$j6d4k rtdA|j$j6 dBtjd td |j$j6dks|j$j6d4krt7d u rtdCtjd |8dDd n|j$j6d4krt9 |j$_6|:  |;  | jrKz*t<| jdEdFdG}
|j=>|
 |?| |@ }W d    n	1 s%w   Y  W n( t)yJ } zt|tjd td W Y d }~nd }~ww |?| |@ }|tAuratBCdHtD |}|r|j$jErptd4 d S |F rt| jjGp}d d S |d ur||j$jHkrtd4 d S t| jjG d S d S )INFT)version	init-hookrcfileload-pluginsverboseoutput)file    r4   callbackr/   stringz<file>z%Specify a configuration file to load.)actionr:   grouptypemetavarhelpr7   zSpecify an output file.r3   z<code>r   zRPython code to execute, usually for sys.path manipulation such as pygtk.require().)r<   r:   r>   r?   r*   r@   zhelp-msgz<msg-id>zqDisplay a help message for the given message id and exit. The value may be a comma separated list of message ids.)r<   r>   r?   r:   r=   r@   z	list-msgsziDisplay a list of all pylint's messages divided by whether they are emittable with the given interpreter.)r<   r?   r:   r=   r*   r@   zlist-msgs-enabledzeDisplay a list of what messages are enabled, disabled and non-emittable with the given configuration.zlist-groupszList pylint's message groups.zlist-conf-levelsz$Generate pylint's confidence levels.)r<   r:   r=   r*   r@   zlist-extensionszList available extensions.zfull-documentationz%Generate pylint's full documentation.zgenerate-rcfilezGenerate 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<   r:   r=   r@   zgenerate-manzGenerate pylint's man page.)r<   r:   r=   r@   hidezerrors-onlyEzIn 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<   r:   shortr@   r6   vzBIn verbose mode, extra non-checker-related info will be displayed.)option_groupspylintrcr   zEnvironment variables)r*   Outputa5  Using 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.
zOutput 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
Izc-extension-no-memberr6   MASTERr5      zJobs number (z&) should be greater than or equal to 0z>Multiprocessing library is missing, fallback to single processjobswzutf-8)encodingzHdo_exit is deprecated and it is going to be removed in a future version.)I_rcfile_output_version_asked_pluginsr6   r	   version_askedr-   cb_set_rcfilecb_add_pluginscb_verbose_modecb_set_outputr   r   r    stderrr!   LinterClassr.   r1   cb_help_messagecb_list_messagescb_list_messages_enabledcb_list_groupsr+   r(   cb_full_documentationcb_generate_configcb_generate_manpagecb_error_moderE   linterr   load_default_pluginsload_plugin_modulesadd_help_sectionr   ENV_HELPdisableenableread_config_fileOSErrorcfgfile_parser
has_optionr
   _unquoteget_splitstripload_config_fileset_reporterload_command_line_configuration
SystemExitcoder@   rL   r   
set_optionr   load_plugin_configurationenable_fail_on_messagesopenreporter
set_outputcheckgenerate_reportsUNUSED_PARAM_SENTINELwarningswarnDeprecationWarning	exit_zeroany_fail_on_issues
msg_status
fail_under)selfr0   ry   r!   do_exitexrb   config_parserpluginsexcr7   score_valuer   r   r   __init__J   s      #














zRun.__init__c                 C   s
   d| _ dS )z1callback for version (i.e. before option parsing)TN)rQ   )r   r   __r   r   r   rS        
zRun.version_askedc                 C   
   || _ dS z>callback for option preprocessing (i.e. before option parsing)N)rO   r   namer$   r   r   r   rT     r   zRun.cb_set_rcfilec                 C   r   r   )rP   r   r   r   r   rW     r   zRun.cb_set_outputc                 C   s   | j t| dS r   )rR   extendr
   ro   r   r   r   r   rU     s   zRun.cb_add_pluginsc                 O   s   | j   dS )zerror 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)rb   
error_moder   r0   kwargsr   r   r   ra     s   zRun.cb_error_modec                 O   s   | j jdd td dS )0optik callback for sample config file generation)COMMANDS)skipsectionsr   N)rb   generate_configr    r!   r   r   r   r   r_     s   zRun.cb_generate_configc                 O   s   | j t td dS )r   r   N)rb   generate_manpager   r    r!   r   r   r   r   r`        zRun.cb_generate_manpagec                 C   s"   | j jt| td dS )z@optik callback for printing some help about a particular messager   N)rb   
msgs_storehelp_messager
   ro   r    r!   r   r"   r#   r$   r%   r   r   r   rZ     s   zRun.cb_help_messagec                 C      | j   td dS )z.optik callback for printing full documentationr   N)rb   print_full_documentationr    r!   r   r   r   r   r^        
zRun.cb_full_documentationc                 C   s   | j j  td dS z.optik callback for printing available messagesr   N)rb   r   list_messagesr    r!   r   r   r   r   r[     r   zRun.cb_list_messagesc                 C   r   r   )rb   list_messages_enabledr    r!   r   r   r   r   r\     r   zRun.cb_list_messages_enabledc                 O   s&   | j  D ]}t| qtd dS )zList all the check groups that pylint knows about

        These should be useful to know what check groups someone can disable
        or enable.
        r   N)rb   get_checker_namesr   r    r!   )r   r0   r   r{   r   r   r   r]     s   
zRun.cb_list_groupsc                 O   s
   d| _ d S )NTrI   r   r   r   r   rV     s   
zRun.cb_verbose_mode)__name__
__module____qualname____doc__r   rY   rE   staticmethodr1   r}   r   rS   rT   rW   rU   ra   r_   r`   rZ   r^   r[   r\   r]   rV   r   r   r   r   r.   7   s2    

  D

r.   )r   r    r~   pylintr   r   r   r   pylint.constantsr   pylint.lint.pylinterr   pylint.lint.utilsr   r	   pylint.utilsr
   r   ImportErrorintr   r(   r+   r-   objectr}   r.   r   r   r   r   <module>   s&   
