
    e]"                    ^   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l	m
Z
 d dlmZ d dlmZ d dlmZmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZ d dlmZmZ d dlm Z  	 d dl!Z!d dl!m"Z" 	 d dl$m%Z% ddZ&ddZ' G d d      Z( G d de(      Z)y# e#$ r dZ!Y .w xY w# e#$ r dZ%Y 4w xY w)    )annotationsN)Sequence)Path)ClassVar)config)clear_lru_caches)_handle_pylint_config_commands!_register_generate_config_options)_config_initialization)ArgumentPreprocessingError)_preprocess_options)full_version)_make_run_options)MANAGERPyLinter)BaseReporter)synchronize)ProcessPoolExecutorc                    d\  } }t        d      j                         r=t        dd      5 }t        |j	                         j                               } ddd       | rj| dk7  ret        d      j                         rLt        dd      5 }t        |j	                         j                               }ddd       t        | z        }ndt        d      j                         rKt        dd      5 }t        |j	                         j                               }ddd       t        d	z        }|d
k(  rd}|S # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   8xY w)zTry to determine number of CPUs allotted in a docker container.

    This is based on discussion and copied from suggestions in
    https://bugs.python.org/issue36054.
    )NNz#/sys/fs/cgroup/cpu/cpu.cfs_quota_usutf-8encodingNz$/sys/fs/cgroup/cpu/cpu.cfs_period_usz/sys/fs/cgroup/cpu/cpu.sharesi   r      )r   is_fileopenintreadrstrip)	cpu_quota	avail_cpufile
cpu_period
cpu_sharess        1/usr/lib/python3/dist-packages/pylint/lint/run.py
_query_cpur&   (   s7    &Iy12::<7'J 	2dDIIK..01I	2
 	O78@@B87K 	3tTYY[//12J	3 	J./		-	.	6	6	81GD 	3TYY[//12J	3 
T)*	
 A~	5	2 	2	3 	3	3 	3s#   (D5	(E.(E5D>E
Ec                     t               } d}t        t        dd      }|rt         |d            }nt        rt	        j
                         }nd}t        j                  dk(  rt        |d      }| t        | |      S |S )zWUse sched_affinity if available for virtualized or containerized
    environments.
    Nsched_getaffinityr   r   win328   )	r&   getattroslenmultiprocessing	cpu_countsysplatformmin)	cpu_sharer/   r(   s      r%   
_cpu_countr4   N   sz     II$7>)!,-		#--/		
||w	2&	9i((    c                  F    e Zd ZU dZeZdZdZded<   	 	 	 d	 	 	 	 	 	 	 d	dZ	y)
RunzAHelper class to use as main for pylint with 'run(*sys.argv[1:])'.))CommandszROptions which are actually commands. Options in this group are mutually exclusive.FClassVar[bool]_is_pylint_configNc                D
   d|v r$t        t               t        j                  d       d | _        d | _        g | _        d| _        	 t        | |      }| j                  0t        t        j                         d       }|rt        |      | _        | j                  t!        |       | j"                  | j                        x| _        }|j'                          |j)                  | j                         | j*                  rt-        |j.                         t1        |||| j                  | j                        }| j*                  r?t3        j4                  dt6        d	
       t9        |      }|rt        j                  |       y |r?t;        |j                  j<                        t;        |j>                  j@                        k(  r t        d       t        j                  d       |j                  jB                  dk  rHt        d|j                  jB                   dt        j                         t        j                  d       |j                  jB                  dkD  s|j                  jB                  dk(  rftD        .t        dt        j                         |jG                  dd       n2|j                  jB                  dk(  rtI               |j                  _!        | j
                  rU	 tK        | j
                  dd      5 }||jL                  _'        |jQ                  |       |jS                         }	d d d        n!|jQ                  |       |jS                         }	|j                  jV                  rtY                t[        j\                          |r|j                  j^                  rt        j                  d       y |ja                         r.t        j                  | j$                  jb                  xs d       y 	]|	|j                  jd                  k\  rt        j                  d       y t        j                  | j$                  jb                  xs d       y t        j                  | j$                  jb                         y y # t        $ r;}t        |t        j                         t        j                  d       Y d }~td }~ww xY w# 1 sw Y   xY w# tT        $ r;}t        |t        j                         t        j                  d       Y d }~d }~ww xY w)Nz	--versionr   F)r"       )option_groupspylintrc)config_fileverbose_modezFNOTE: The 'pylint-config' command is experimental and usage can change   )
stacklevelzNo files to lint: exiting.zJobs number (z&) should be greater than or equal to 0r   z@concurrent.futures module is missing, fallback to single processjobswr   r   )3printr   r0   exit_rcfile_output_pluginsverboser   r   stderrnextr   find_default_config_filesstrLinterClassr   r=   linterload_default_pluginsload_plugin_modulesr:   r
   _arg_parserr   warningswarnUserWarningr	   r-   disable
msgs_store_messages_definitionsrC   r   
set_optionr4   r   reporteroutcheckgenerate_reportsOSErrorclear_cache_post_runr   r   clear_cache	exit_zeroany_fail_on_issues
msg_status
fail_under)
selfargsr[   rF   exdefault_filerP   codeoutputscore_values
             r%   __init__zRun.__init__v   s    $,HHQK#'#'#%"	&tT2D << @ @ BDIL"<0#//d#,,\\  0  
 	
f 	##%""4==1 !!-f.@.@A%D(4<<

 !!MMX
 2&9D s6==001S336
 
 ./HHRL==! 2 233YZZZ HHRL==!V]]%7%71%<"*V !!&!,##q(%/\"<<$,,g> <&*0FOO'LL&"("9"9";K< LL 113K==--!}}&&**, //415(&--":"::HHQK HHT[[338q9//0 a * 	"3::&HHRLL	D< <  bszz*sH   R (S  3S3S 	S0SSSS 	T$0TT)NT)rg   zSequence[str]r[   zBaseReporter | NonerF   boolreturnNone)
__name__
__module____qualname____doc__r   rO   r=   r:   __annotations__rm    r5   r%   r7   r7   d   s[    KKM ).~- )-	r1r1 &r1 	r1
 
r1r5   r7   c                       e Zd ZU dZdZded<   y)_PylintConfigRunz2A private wrapper for the 'pylint-config' command.Tr9   r:   N)rq   rr   rs   rt   r:   ru   rv   r5   r%   rx   rx      s    <(,~,r5   rx   )ro   z
int | None)ro   r   )*
__future__r   r,   r0   rT   collections.abcr   pathlibr   typingr   pylintr   pylint.checkers.utilsr   pylint.config._pylint_configr	   r
   #pylint.config.config_initializationr   pylint.config.exceptionsr   pylint.config.utilsr   pylint.constantsr   pylint.lint.base_optionsr   pylint.lint.pylinterr   r   pylint.reporters.base_reporterr   r.   r   ImportErrorconcurrent.futuresr   r&   r4   r7   rx   rv   r5   r%   <module>r      s   
 # 	 
  $    2 G ? 3 ) 6 2 7+6
#L,D1 D1Ns Y  O
  s$   &
B 1B" BB"B,+B,