
    ,h;                        d Z ddlmZ ddlZddlZddlZddlZddlmZ ddl	m
Z
mZ ddlmZ ddlmZmZ dd	lmZ  G d
 d      Zd Z G d de      Zej.                  fddZd ZddZy)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                     e Zd ZdZdddZddZej                  fddZddZ	ddZ
ddZdd	Zdd
Zd ZddZe	 	 	 d	 	 	 	 	 	 	 	 	 dd       Ze	 	 d 	 	 	 	 	 	 	 	 	 d!d       Ze	 	 	 	 	 	 	 	 	 	 d!d       Z	 	 	 d	 	 	 	 	 	 	 	 	 d"dZe	 	 	 d	 	 	 	 	 	 	 	 	 dd       Ze	 	 d 	 	 	 	 	 	 	 	 	 d!d       Ze	 	 	 	 	 	 	 	 	 	 d!d       Z	 	 	 d	 	 	 	 	 	 	 	 	 d"dZy)#FileLista  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                     d | _         g | _        y N)allfilesfiles)selfwarndebug_prints      `/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/setuptools/_distutils/filelist.py__init__zFileList.__init__$   s     /3 "
    c                    || _         y r   )r   )r   r   s     r   set_allfileszFileList.set_allfiles*   s	     r   c                $    t        |      | _        y r   )findallr   )r   dirs     r   r   zFileList.findall-   s    r   c                ,    ddl m} |rt        |       yy)z~Print '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   zFileList.debug_print0   s     	*#J r   c                :    | j                   j                  |       y r   )r   append)r   items     r   r#   zFileList.append;   s    

$r   c                :    | j                   j                  |       y r   )r   extend)r   itemss     r   r&   zFileList.extend>   s    

% r   c                    t        t        t        j                  j                  | j
                              }g | _        |D ]7  }| j
                  j                  t        j                  j                  |        9 y r   )sortedmapospathsplitr   r#   join)r   sortable_files
sort_tuples      r   sortzFileList.sortA   sT    BGGMM4:: >?
( 	9JJJbggllJ78	9r   c                    t        t        | j                        dz
  dd      D ]2  }| j                  |   | j                  |dz
     k(  s&| j                  |= 4 y )Nr   r   )rangelenr   )r   is     r   remove_duplicateszFileList.remove_duplicatesJ   sO    s4::*Ar2 	"Azz!}

1q5 11JJqM	"r   c                   |j                         }|d   }d x}x}}|dv r9t        |      dk  rt        d| d      |dd  D cg c]  }t        |       }}n|dv rGt        |      dk  rt        d| d	      t        |d         }|dd  D cg c]  }t        |       }}n?|d
v r,t        |      dk7  rt        d| d      t        |d         }nt        d| d      ||||fS c c}w c c}w )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 ')r-   r5   r
   r   )r   linewordsactionpatternsr   dir_patternws           r   _parse_template_linezFileList._parse_template_lineR   s9   

q'+++3OO5zA~,xBC  27qr;AQ;H;AA5zA~,xHI  uQx(C16qr;AQ;H;))5zQ,x?@  'uQx0K(+;F81)EFF#{33# < <s   C)C.c                   | j                  |      \  }}}}|dk(  rU| j                  ddj                  |      z          |D ],  }| j                  |d      rt	        j
                  d|       . y |dk(  rU| j                  ddj                  |      z          |D ],  }| j                  |d      rt	        j
                  d	|       . y |d
k(  rU| j                  ddj                  |      z          |D ],  }| j                  |d      rt	        j
                  d|       . y |dk(  rU| j                  ddj                  |      z          |D ],  }| j                  |d      rt	        j
                  d|       . y |dk(  re| j                  dj                  |dj                  |                   |D ]/  }| j                  ||      rd}t	        j
                  |||       1 y |dk(  rc| j                  dj                  |dj                  |                   |D ]-  }| j                  ||      rt	        j
                  d||       / y |dk(  r?| j                  d|z          | j                  d |      st	        j
                  d|       y y |dk(  r?| j                  d|z          | j                  d |      st	        j
                  d|       y y t        d| d      ) Nr9   zinclude  T)anchorz%warning: no files found matching '%s'r:   zexclude z9warning: no previously-included files found matching '%s'r;   zglobal-include Fz>warning: no files found matching '%s' anywhere in distributionr<   zglobal-exclude zRwarning: no previously-included files matching '%s' found anywhere in distributionr?   zrecursive-include {} {})prefixz:warning: no files found matching '%s' under directory '%s'r@   zrecursive-exclude {} {}zNwarning: no previously-included files matching '%s' found under directory '%s'rB   zgraft z+warning: no directories found matching '%s'rC   zprune z6no previously-included directories found matching '%s'z$this cannot happen: invalid action 'r>   )	rJ   r   r.   include_patternr   warningexclude_patternformatr	   )r   rD   rF   rG   r   rH   patternr!   s           r   process_template_linezFileList.process_template_linep   s    04/H/H/N,3
 YZ#((8*<<=# R++GD+AKK GQR y Z#((8*<<=# ++GD+AKKS ''.(1CCD# ++GE+BKK7   ''.(1CCD# ++GE+BKKB   **6==c388HCUVW# 3++GC+@VCKKWc23
 **6==c388HCUVW# 	++GC+@KK>  	 wX34''['AI;W B wX34''['AM B )6vha@ r   c                     y r    r   rS   rM   rN   is_regexs        r   rO   zFileList.include_pattern        r   c                    y r   rV   rW   s        r   rO   zFileList.include_pattern        r   c                     y r   rV   rW   s        r   rO   zFileList.include_pattern   rY   r   c                D   d}t        ||||      }| j                  d|j                   d       | j                  | j	                          | j                  D ]E  }|j                  |      s| j                  d|z          | j                  j                  |       d}G |S )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'r>   z adding T)translate_patternr   rS   r   r   searchr   r#   )r   rS   rM   rN   rX   files_found
pattern_renames           r   rO   zFileList.include_pattern   s    @ &wI
=j>P>P=QQRST == LLNMM 	#D  &  d!23

!!$'"		#
 r   c                     y r   rV   rW   s        r   rQ   zFileList.exclude_pattern  rY   r   c                    y r   rV   rW   s        r   rQ   zFileList.exclude_pattern  r[   r   c                     y r   rV   rW   s        r   rQ   zFileList.exclude_pattern!  rY   r   c                R   d}t        ||||      }| j                  d|j                   d       t        t	        | j
                        dz
  dd      D ]Q  }|j                  | j
                  |         s"| j                  d| j
                  |   z          | j
                  |= d}S |S )a  Remove 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'r>   r   r3   z
 removing T)r^   r   rS   r4   r5   r   r_   )r   rS   rM   rN   rX   r`   ra   r6   s           r   rQ   zFileList.exclude_pattern)  s     &wI
=j>P>P=QQRSTs4::*B3 	#A  A/  

1!=>JJqM"		#
 r   )NN)r   objectr   rg   returnNone)r   Iterable[str]rh   ri   )r   str | os.PathLike[str]rh   ri   )r!   rg   rh   ri   )r$   strrh   ri   )r'   rj   rh   ri   )rh   ri   )rD   rl   rh   ri   TNF)
rS   rl   rM   boolrN   
str | NonerX   zLiteral[False]rh   rn   )TN)
rS   zstr | re.Pattern[str]rM   rn   rN   ro   rX   zLiteral[True]rh   rn   )
rS   zstr | re.PatternrM   rn   rN   ro   rX   rn   rh   rn   )__name__
__module____qualname____doc__r   r   r+   curdirr   r   r#   r&   r1   r7   rJ   rT   r   rO   rQ   rV   r   r   r   r      s   #! 57II % !9"4<Up  !#(  	
 ! 
   !	&  	   
  &  	
   
  !-!- - 	-
 - 
-^  !#(  	
 ! 
   !	&  	   
  &  	
   
  !!  	
  
r   r   c                    t         j                  t        j                  | d            }d |D        }t        t        j                  j
                  |      S )z%
    Find all files under 'path'
    T)followlinksc              3  r   K   | ]/  \  }}}|D ]$  }t         j                  j                  ||       & 1 y wr   )r+   r,   r.   ).0basedirsr   files        r   	<genexpr>z#_find_all_simple.<locals>.<genexpr>I  s=      %6T4QVIMT4  s   57)_UniqueDirsfilterr+   walkr,   isfile)r,   
all_uniqueresultss      r   _find_all_simpler   D  sE     ##BGGDd$CDJ:DG "''..'**r   c                  &    e Zd ZdZd Zed        Zy)r}   z
    Exclude previously-seen dirs from walk results,
    avoiding infinite recursion.
    Ref https://bugs.python.org/issue44497.
    c                    |\  }}}t        j                  |      }|j                  |j                  f}|| v }|r|dd= | j	                  |       | S )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)r+   statst_devst_inoadd)r   	walk_itemry   rz   r   r   	candidatefounds           r   __call__z_UniqueDirs.__call__V  sW     &dEwwt}KK,	T!Qyr   c                $    t         |        |      S r   )r~   )clsr'   s     r   r~   z_UniqueDirs.filtere  s    ceU##r   N)rp   rq   rr   rs   r   classmethodr~   rV   r   r   r}   r}   O  s      $ $r   r}   c                    t        |       }| t        j                  k(  r;t        j                  t        j
                  j                  |       }t        ||      }t        |      S )z
    Find all files under 'dir' and return the list of full filenames.
    Unless dir is '.', return full filenames with dir prepended.
    )start)	r   r+   rt   	functoolspartialr,   relpathr*   list)r   r   make_rels      r   r   r   j  sJ    
 S!E
bii$$RWW__C@He$;r   c                    t        j                  |       }t        j                  }t        j                  dk(  rd}d| d}t	        j
                  d||      }|S )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	translater+   sepresub)rS   ra   r   escapeds       r   
glob_to_rer   v  sW     ""7+J &&C	vv~ cU!nG-w
CJr   c                   |r't        | t              rt        j                  |       S | S t	        d      j                  d      \  }}}| r/t	        |       }|j                  |      r|j                  |      sJ d}|t	        |      }|j                  |      r|j                  |      sJ |t        |      t        |      t        |      z
   }t        j                  }	t        j                  dk(  rd}	|t        |      t        |      t        |      z
   }| d| |	 d| | }n|r| d|t        |      d  }t        j                  |      S )a  Translate 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.*)
isinstancerl   r   compiler   	partition
startswithendswithr5   r+   r   )
rS   rM   rN   rX   r   r   endra   	prefix_rer   s
             r   r^   r^     s>    gs#::g&&N sO--c2ME1c(
$$U+
0C0CC0HH
v&	##E*y/A/A#/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   rk   rm   )rs   
__future__r   r   r   r+   r   collections.abcr   typingr   r   _logr   errorsr	   r
   utilr   r   r   setr}   rt   r   r   r^   rV   r   r   <module>r      s`    #   	 	 $ $  B i i^	+$# $6 +-)) 	.""r   