
    e&                        d dl m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mZ ddZddZdd	Z	 	 	 	 	 	 	 	 	 	 dd
Z	 	 	 	 	 	 	 	 	 	 	 	 ddZy)    )annotationsN)Sequence)Pattern)modutils)ErrorDescriptionDictModuleDescriptionDictc                @    dfd}t        j                  | ||      S )Nc                8    t        j                  | |      xs S N)r   check_modpath_has_init)
inner_pathpartsis_namespaces     </usr/lib/python3/dist-packages/pylint/lint/expand_modules.py_is_package_cbz*_modpath_from_file.<locals>._is_package_cb   s    ..z5AQ\Q    )pathis_package_cb)r   strr   	list[str]returnbool)r   modpath_from_file_with_callback)filenamer   r   r   s    `  r   _modpath_from_filer      s%    R 33t> r   c                   t         j                  j                  t         j                  j                  |             }t         j                  j	                  |      st         j                  j                  |      }|D ]f  }t         j                  j                  t         j                  j                  |            }t         j                  j                  ||g      |k(  sd|c S  	 t         j                  j                  t         j                  j                  |d            s|S |}t         j                  j                  |      }||k(  rt        j                         S z)z<Discover package path from one its modules and source roots.__init__.py)
osr   realpath
expanduserisdirdirname
commonpathexistsjoingetcwd)
modulepathsource_rootsr"   source_rootold_dirnames        r   discover_package_pathr+      s    ggrww11*=>G77==!''//'* $ gg&&rww'9'9+'FG77{G45D ww~~bggll7MBCN''//'*'!99; r   c                ,     t         fd|D              S )z<Determines if the element is matched in a regex ignore-list.c              3  @   K   | ]  }|j                          y wr   )match).0file_patternelements     r   	<genexpr>z(_is_in_ignore_list_re.<locals>.<genexpr>3   s     N||!!'*Ns   )any)r1   ignore_list_res   ` r   _is_in_ignore_list_rer5   1   s    N~NNNr   c                    t         j                  j                  |       } t         j                  j                  |       }||v xs t	        ||      xs t	        | |      S r   )r   r   normpathbasenamer5   )r1   ignore_listr4   ignore_list_paths_rer8   s        r   _is_ignored_filer;   6   sZ     ggw'Gww(HK 	@ >:	@ *>?r   c                   i }g }t         j                  j                         }| D ]  }t        j                  j	                  |      }	t        ||||      r2t        ||      }
d|
g|}t        j                  j                  |      rj	 dj                  t        j                  ||            }t        j                  j                  |      r!t        j                  j                  |d      }n0|}n-|}	 t        j                  |j                  d      |      }|	 t        j                  j#                  |      }|xs |j                  d      }	 t        j$                  ||      }t        j&                  |      }t        j(                  |      }|s||v r	d	||   d
<   n||d	||d||<   |j+                  d      xs |dk(   xr" t        j                  j	                  |      dk(  }|s|s|st        j,                  t        j                  j/                  |      xs d||      D ]  }t        j                  j#                  |      }||k(  r(t1        t        j                  j	                  |      |      st1        ||      r^t3        |||      }dj                  |      }||v xr ||   d
   }|||||d||<     ||fS # t        $ r& t        j                  j                  |	      d   }Y Kw xY w# t        $ r }|j!                  d||d       Y d}~d}~ww xY w# t        $ r% d}t        j                  j                  |      }Y w xY w)zTake a list of files/modules/packages and return the list of tuple
    (file, module name) which have to be actually checked.
    .)r   r   r   Nfatal)keymodexFTisarg)r   namerB   basepathr8   z	.__init____init__)list_all)sysr   copyr   r8   r;   r+   r$   r%   r   modpath_from_fileImportErrorsplitextr!   file_from_modpathsplitappendr7   file_info_from_modpathr   is_directoryendswithget_module_filesr"   r5   r   )files_or_modulesr(   r9   r4   r:   resulterrorsr   	somethingr8   module_package_pathadditional_search_pathmodnamefilepathrA   modpartsspecr   rP   has_initsubfilepathmodpath
submodnamerB   s                           r   expand_modulesra   F   sR    02F)+F88==?D% U	77##I.{N4H
 3I|L"%':!BT!B77>>)$8((..y?UV
 ww}}Y'77<<	=A$  G#55MM#&-C # $
 77##H-(y//4
	7225D $006L#006L6!,0x ) %#! ( '$x  !!+.G'Z2GH <  *m; 	 ||'88)0S+   !gg..{;{*(GG$$[1>*;8LM,4J !XXg.
#v-N&2Eg2N'&" ( ''{##}Ul 6>Q  8''**84Q78  ggRHI  	4 L77==3L	4s<   	&K5(K>L*+K;:K;>	L'L""L'**MM)r   r   r   r   r   r   r   r   )r'   r   r(   Sequence[str]r   r   )r1   r   r4   list[Pattern[str]]r   r   )
r1   r   r9   r   r4   rc   r:   rc   r   r   )rS   rb   r(   rb   r9   r   r4   rc   r:   rc   r   zCtuple[dict[str, ModuleDescriptionDict], list[ErrorDescriptionDict]])
__future__r   r   rG   collections.abcr   rer   astroidr   pylint.typingr   r   r   r+   r5   r;   ra    r   r   <module>rj      s   
 # 	 
 $   E.O
 ' -	
 
 d#dd d '	d
 -d Idr   