
    n&ph;                        S r SSKJr  SSKrSSKrSSKrSSKrSSKJr  SSK	J
r
Jr  SSKJr  SSKJrJr  SS	KJr   " S
 S5      rS r " S S\5      r\R.                  4SS jjrS rSS jrg)zsdistutils.filelist

Provides the FileList class, used for poking about the filesystem
and building lists of files.
    )annotationsN)Iterable)Literaloverload   )log)DistutilsInternalErrorDistutilsTemplateError)convert_pathc                     \ rS rSrSrSSS jjrSS jr\R                  4SS jjr	SS jr
SS jrSS	 jrSS
 jrSS jrS rSS jr\   S          S!S jj5       r\  S"         S#S jj5       r\          S#S j5       r   S          S$S jjr\   S          S!S jj5       r\  S"         S#S jj5       r\          S#S j5       r   S          S$S jjrSrg)%FileList   a  A list of files built by on exploring the filesystem and filtered by
applying various patterns to what we find there.

Instance attributes:
  dir
    directory from which files will be taken -- only used if
    'allfiles' not supplied to constructor
  files
    list of filenames currently being built/filtered/manipulated
  allfiles
    complete list of files under consideration (ie. without any
    filtering applied)
Nc                     S U l         / U l        g Nallfilesfiles)selfwarndebug_prints      Q/var/www/html/venv/lib/python3.13/site-packages/setuptools/_distutils/filelist.py__init__FileList.__init__$   s     /3 "
    c                    Xl         g r   )r   )r   r   s     r   set_allfilesFileList.set_allfiles*   s     r   c                $    [        U5      U l        g r   )findallr   )r   dirs     r   r   FileList.findall-   s    r   c                6    SSK Jn  U(       a  [        U5        gg)znPrint 'msg' to stdout if the global DEBUG (taken from the
DISTUTILS_DEBUG environment variable) flag is true.
r   )DEBUGN)distutils.debugr#   print)r   msgr#   s      r   r   FileList.debug_print0   s     	*#J r   c                :    U R                   R                  U5        g r   )r   append)r   items     r   r)   FileList.append;   s    

$r   c                :    U R                   R                  U5        g r   )r   extend)r   itemss     r   r-   FileList.extend>   s    

% r   c                    [        [        [        R                  R                  U R
                  5      5      n/ U l        U H9  nU R
                  R                  [        R                  R                  " U6 5        M;     g r   )sortedmapospathsplitr   r)   join)r   sortable_files
sort_tuples      r   sortFileList.sortA   sO    BGGMM4:: >?
(JJJbggllJ78 )r   c                    [        [        U R                  5      S-
  SS5       H5  nU R                  U   U R                  US-
     :X  d  M(  U R                  U	 M7     g )Nr   r   )rangelenr   )r   is     r   remove_duplicatesFileList.remove_duplicatesJ   sJ    s4::*Ar2Azz!}

1q5 11JJqM 3r   c                   UR                  5       nUS   nS =n=pVUS;   a=  [        U5      S:  a  [        SU S35      eUSS   Vs/ s H  n[        U5      PM     nnOUS;   aK  [        U5      S:  a  [        SU S	35      e[        US   5      nUSS   Vs/ s H  n[        U5      PM     nnOBUS
;   a-  [        U5      S:w  a  [        SU S35      e[        US   5      nO[        SU S35      eX4XV4$ s  snf s  snf )Nr   )includeexcludeglobal-includeglobal-exclude   'z#' expects <pattern1> <pattern2> ...r   )recursive-includerecursive-exclude   z)' expects <dir> <pattern1> <pattern2> ...)graftprunez ' expects a single <dir_pattern>zunknown action ')r5   r>   r
   r   )r   linewordsactionpatternsr    dir_patternws           r   _parse_template_lineFileList._parse_template_lineR   s9   

q'+++3OO5zA~,xBC  27qr;AQH;HAA5zA~,xHI  uQx(C16qr;AQH;H))5zQ,x?@  'uQx0K(+;F81)EFF#33# < <s   C5C:c                *   U R                  U5      u  p#pEUS:X  a[  U R                  SSR                  U5      -   5        U H1  nU R                  USS9(       a  M  [        R
                  " SU5        M3     g US:X  a[  U R                  SSR                  U5      -   5        U H1  nU R                  USS9(       a  M  [        R
                  " S	U5        M3     g US
:X  a[  U R                  SSR                  U5      -   5        U H1  nU R                  USS9(       a  M  [        R
                  " SU5        M3     g US:X  a[  U R                  SSR                  U5      -   5        U H1  nU R                  USS9(       a  M  [        R
                  " SU5        M3     g US:X  ai  U R                  SR                  USR                  U5      5      5        U H2  nU R                  XdS9(       a  M  Sn[        R
                  " XvU5        M4     g US:X  ah  U R                  SR                  USR                  U5      5      5        U H1  nU R                  XdS9(       a  M  [        R
                  " SUU5        M3     g US:X  aB  U R                  SU-   5        U R                  S US9(       d  [        R
                  " SU5        g g US:X  aB  U R                  SU-   5        U R                  S US9(       d  [        R
                  " SU5        g g [        SU S35      e) NrC   zinclude  T)anchorz%warning: no files found matching '%s'rD   zexclude z9warning: no previously-included files found matching '%s'rE   zglobal-include Fz>warning: no files found matching '%s' anywhere in distributionrF   zglobal-exclude zRwarning: no previously-included files matching '%s' found anywhere in distributionrI   zrecursive-include {} {})prefixz:warning: no files found matching '%s' under directory '%s'rJ   zrecursive-exclude {} {}zNwarning: no previously-included files matching '%s' found under directory '%s'rL   zgraft z+warning: no directories found matching '%s'rM   zprune z6no previously-included directories found matching '%s'z$this cannot happen: invalid action 'rH   )	rT   r   r6   include_patternr   warningexclude_patternformatr	   )r   rN   rP   rQ   r    rR   patternr&   s           r   process_template_lineFileList.process_template_linep   s    04/H/H/N,3
 YZ#((8*<<=#++GD+AAKK GQ $ y Z#((8*<<=#++GD+AAKKS $ ''.(1CCD#++GE+BBKK7   $ ''.(1CCD#++GE+BBKKB   $ **6==c388HCUVW#++G+@@VCKKc2 $
 **6==c388HCUVW#++G+@@KK>   $ wX34''['AI;W B wX34''['AM B )6vha@ r   c                    g r    r   r^   rX   rY   is_regexs        r   rZ   FileList.include_pattern        r   c                   g r   rb   rc   s        r   rZ   re           r   c                    g r   rb   rc   s        r   rZ   re      rf   r   c                R   Sn[        XX45      nU R                  SUR                   S35        U R                  c  U R	                  5         U R                   HL  nUR                  U5      (       d  M  U R                  SU-   5        U R                  R                  U5        SnMN     U$ )a  Select strings (presumably filenames) from 'self.files' that
match 'pattern', a Unix-style wildcard (glob) pattern.  Patterns
are not quite the same as implemented by the 'fnmatch' module: '*'
and '?'  match non-special characters, where "special" is platform-
dependent: slash on Unix; colon, slash, and backslash on
DOS/Windows; and colon on Mac OS.

If 'anchor' is true (the default), then the pattern match is more
stringent: "*.py" will match "foo.py" but not "foo/bar.py".  If
'anchor' is false, both of these will match.

If 'prefix' is supplied, then only filenames starting with 'prefix'
(itself a pattern) and ending with 'pattern', with anything in between
them, will match.  'anchor' is ignored in this case.

If 'is_regex' is true, 'anchor' and 'prefix' are ignored, and
'pattern' is assumed to be either a string containing a regex or a
regex object -- no translation is done, the regex is just compiled
and used as-is.

Selected strings will be added to self.files.

Return True if files are found, False otherwise.
Fz"include_pattern: applying regex r'rH   z adding T)translate_patternr   r^   r   r   searchr   r)   )r   r^   rX   rY   rd   files_found
pattern_renames           r   rZ   re      s    @ &wI
=j>P>P=QQRST == LLNMMD  &&  d!23

!!$'"	 "
 r   c                    g r   rb   rc   s        r   r\   FileList.exclude_pattern  rf   r   c                   g r   rb   rc   s        r   r\   rq     rh   r   c                    g r   rb   rc   s        r   r\   rq   !  rf   r   c                ^   Sn[        XX45      nU R                  SUR                   S35        [        [	        U R
                  5      S-
  SS5       HX  nUR                  U R
                  U   5      (       d  M(  U R                  SU R
                  U   -   5        U R
                  U	 SnMZ     U$ )zRemove strings (presumably filenames) from 'files' that match
'pattern'.  Other parameters are the same as for
'include_pattern()', above.
The list 'self.files' is modified in place.
Return True if files are found, False otherwise.
Fz"exclude_pattern: applying regex r'rH   r   r<   z
 removing T)rk   r   r^   r=   r>   r   rl   )r   r^   rX   rY   rd   rm   rn   r?   s           r   r\   rq   )  s     &wI
=j>P>P=QQRSTs4::*B3A  A//  

1!=>JJqM"	 4
 r   r   )NN)r   objectr   ru   returnNone)r   Iterable[str]rv   rw   )r    str | os.PathLike[str]rv   rw   )r&   ru   rv   rw   )r*   strrv   rw   )r.   rx   rv   rw   )rv   rw   )rN   rz   rv   rw   TNF)
r^   rz   rX   boolrY   
str | Nonerd   zLiteral[False]rv   r|   )TN)
r^   zstr | re.Pattern[str]rX   r|   rY   r}   rd   zLiteral[True]rv   r|   )
r^   zstr | re.PatternrX   r|   rY   r}   rd   r|   rv   r|   )__name__
__module____qualname____firstlineno____doc__r   r   r3   curdirr   r   r)   r-   r9   r@   rT   r_   r   rZ   r\   __static_attributes__rb   r   r   r   r      s   #! 57II % !9"4<Up  !#(  	
 ! 
   !	&  	   
  &  	
   
  !-!- - 	-
 - 
-^  !#(  	
 ! 
   !	&  	   
  &  	
   
  !!  	
  
 r   r   c                    [         R                  [        R                  " U SS95      nS U 5       n[        [        R                  R
                  U5      $ )z
Find all files under 'path'
T)followlinksc              3  x   #    U  H0  u  po3  H$  n[         R                  R                  X5      v   M&     M2     g 7fr   )r3   r4   r6   ).0basedirsr   files        r   	<genexpr>#_find_all_simple.<locals>.<genexpr>I  s3      :D%6TQVT  QV *s   8:)_UniqueDirsfilterr3   walkr4   isfile)r4   
all_uniqueresultss      r   _find_all_simpler   D  sE     ##BGGDd$CDJ:DG "''..'**r   c                  .    \ rS rSrSrS r\S 5       rSrg)r   iO  zv
Exclude previously-seen dirs from walk results,
avoiding infinite recursion.
Ref https://bugs.python.org/issue44497.
c                    Uu  p#n[         R                  " U5      nUR                  UR                  4nX`;   nU(       a  USS2	 U R	                  U5        U(       + $ )z
Given an item from an os.walk result, determine
if the item represents a unique dir for this instance
and if not, prevent further traversal.
N)r3   statst_devst_inoadd)r   	walk_itemr   r   r   r   	candidatefounds           r   __call___UniqueDirs.__call__V  sS     &Ewwt}KK,	!Qyr   c                $    [        U " 5       U5      $ r   )r   )clsr.   s     r   r   _UniqueDirs.filtere  s    ceU##r   rb   N)	r~   r   r   r   r   r   classmethodr   r   rb   r   r   r   r   O  s      $ $r   r   c                    [        U 5      nU [        R                  :X  a8  [        R                  " [        R
                  R                  U S9n[        X!5      n[        U5      $ )z
Find all files under 'dir' and return the list of full filenames.
Unless dir is '.', return full filenames with dir prepended.
)start)	r   r3   r   	functoolspartialr4   relpathr2   list)r    r   make_rels      r   r   r   j  sH    
 S!E
bii$$RWW__C@H$;r   c                    [         R                  " U 5      n[        R                  n[        R                  S:X  a  SnSU S3n[        R
                  " SX15      nU$ )zTranslate a shell-like glob pattern to a regular expression; return
a string containing the regex.  Differs from 'fnmatch.translate()' in
that '*' does not match "special characters" (which are
platform-specific).
\z\\\\z\1[^]z((?<!\\)(\\\\)*)\.)fnmatch	translater3   sepresub)r^   rn   r   escapeds       r   
glob_to_rer   v  sU     ""7+J &&C	vv~ cU!nG-wCJr   c                   U(       a-  [        U [        5      (       a  [        R                  " U 5      $ U $ [	        S5      R                  S5      u  pEnU (       a:  [	        U 5      nUR                  U5      (       a  UR                  U5      (       d   eOSnUb  [	        U5      nUR                  U5      (       a  UR                  U5      (       d   eU[        U5      [        U5      [        U5      -
   n[        R                  n	[        R                  S:X  a  Sn	U[        U5      [        U5      [        U5      -
   nU SU U	 SU U 3nOU(       a  U SU[        U5      S  3n[        R                  " U5      $ )zTranslate a shell-like wildcard pattern to a compiled regular
expression.  Return the compiled regex.  If 'is_regex' true,
then 'pattern' is directly compiled to a regex (if it's a string)
or just returned as-is (assumes it's a regex object).
_ Nr   z\\z\Az.*)
isinstancerz   r   compiler   	partition
startswithendswithr>   r3   r   )
r^   rX   rY   rd   r   r   endrn   	prefix_rer   s
             r   rk   rk     sT    gs##::g&&N sO--c2MEc(
$$U++
0C0CC0H0HHH0H
v&	##E**y/A/A#/F/FFFc%j3y>CH+DE	ff66T>CE
S_s3x-GH
r)SEJ<uE
"G2jU&>%?@J::j!!r   )r    ry   r{   )r   
__future__r   r   r   r3   r   collections.abcr   typingr   r   _logr   errorsr	   r
   utilr   r   r   setr   r   r   r   rk   rb   r   r   <module>r      s`    #   	 	 $ $  B i i^	+$# $6 +-)) 	.""r   