§
    ZQd 2  ã                   ó”   — d 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  G d„ d¦  «        Zd„ Zej        fd	„Zd
„ Zdd„ZdS )zsdistutils.filelist

Provides the FileList class, used for poking about the filesystem
and building lists of files.
é    N©Úconvert_path)ÚDistutilsTemplateErrorÚDistutilsInternalError)Úlogc                   óp   — e Zd ZdZdd„Zd„ Zej        fd„Zd„ Z	d„ Z
d„ Zd	„ Zd
„ Zd„ Zd„ Zdd„Z	 dd„ZdS )Ú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 | _        d S ©N)ÚallfilesÚfiles)ÚselfÚwarnÚdebug_prints      ú)/usr/lib/python3.11/distutils/filelist.pyÚ__init__zFileList.__init__   s   € ð ˆŒØˆŒ
ˆ
ˆ
ó    c                 ó   — || _         d S r   )r   )r   r   s     r   Úset_allfileszFileList.set_allfiles#   s   € Ø ˆŒˆˆr   c                 ó.   — t          |¦  «        | _        d S r   )Úfindallr   )r   Údirs     r   r   zFileList.findall&   s   € Ý ™œˆŒˆˆr   c                 ó8   — ddl m} |rt          |¦  «         dS dS )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_print)   s7   € ð 	*Ð)Ð)Ð)Ð)Ð)Øð 	Ý�#‰JŒJˆJˆJˆJð	ð 	r   c                 ó:   — | j                              |¦  «         d S r   )r   Úappend)r   Úitems     r   r   zFileList.append3   s   € ØŒ
×Ò˜$ÑÔÐÐÐr   c                 ó:   — | j                              |¦  «         d S r   )r   Úextend)r   Úitemss     r   r"   zFileList.extend6   s   € ØŒ
×Ò˜%Ñ Ô Ð Ð Ð r   c                 óÖ   — t          t          t          j        j        | j        ¦  «        ¦  «        }g | _        |D ]-}| j                             t          j        j        |Ž ¦  «         Œ.d S r   )ÚsortedÚmapÚosÚpathÚsplitr   r   Újoin)r   Úsortable_filesÚ
sort_tuples      r   ÚsortzFileList.sort9   sa   € å¥¥B¤G¤M°4´:Ñ >Ô >Ñ?Ô?ˆØˆŒ
Ø(ð 	9ð 	9ˆJØŒJ×Ò�bœgœl¨JÐ7Ñ8Ô8Ð8Ð8ð	9ð 	9r   c                 ó¦   — t          t          | j        ¦  «        dz
  dd¦  «        D ])}| j        |         | j        |dz
           k    r| j        |= Œ*d S )Né   r   éÿÿÿÿ)ÚrangeÚlenr   )r   Úis     r   Úremove_duplicateszFileList.remove_duplicatesC   sZ   € å•s˜4œ:‘”¨Ñ*¨A¨rÑ2Ô2ð 	"ð 	"ˆAØŒz˜!Œ} ¤
¨1¨q©5Ô 1Ò1Ð1Ø”J˜q�Møð	"ð 	"r   c                 ó  — |                      ¦   «         }|d         }d x}x}}|dv r:t          |¦  «        dk     rt          d|z  ¦  «        ‚d„ |dd …         D ¦   «         }n¤|dv rOt          |¦  «        dk     rt          d	|z  ¦  «        ‚t          |d         ¦  «        }d
„ |dd …         D ¦   «         }nQ|dv r;t          |¦  «        dk    rt          d|z  ¦  «        ‚t          |d         ¦  «        }nt          d|z  ¦  «        ‚||||fS )Nr   )ÚincludeÚexcludeúglobal-includeúglobal-excludeé   z&'%s' expects <pattern1> <pattern2> ...c                 ó,   — g | ]}t          |¦  «        ‘ŒS © r   ©Ú.0Úws     r   ú
<listcomp>z1FileList._parse_template_line.<locals>.<listcomp>W   ó   € Ð;Ð;Ð;¨A� Q™œÐ;Ð;Ð;r   r/   )úrecursive-includeúrecursive-excludeé   z,'%s' expects <dir> <pattern1> <pattern2> ...c                 ó,   — g | ]}t          |¦  «        ‘ŒS r<   r   r=   s     r   r@   z1FileList._parse_template_line.<locals>.<listcomp>]   rA   r   )ÚgraftÚprunez#'%s' expects a single <dir_pattern>zunknown action '%s')r)   r2   r   r   )r   ÚlineÚwordsÚactionÚpatternsr   Údir_patterns          r   Ú_parse_template_linezFileList._parse_template_lineL   sV  € Ø—
’
‘”ˆØ�q”ˆà'+Ð+ˆÐ+�3˜àð :ð :ð :å�5‰zŒz˜AŠ~ˆ~Ý,Ø>ÀÑGñIô Ið Ià;Ð;°°q°r°r´Ð;Ñ;Ô;ˆHˆHØÐAÐAÐAÝ�5‰zŒz˜AŠ~ˆ~Ý,ØDÀvÑMñOô Oð Oå˜u QœxÑ(Ô(ˆCØ;Ð;°°q°r°r´Ð;Ñ;Ô;ˆHˆHØÐ)Ð)Ð)Ý�5‰zŒz˜QŠˆÝ,Ø;¸fÑDñFô Fð Få& u¨Q¤xÑ0Ô0ˆKˆKå(Ð)>ÀÑ)GÑHÔHÐHà˜ # {Ð3Ð3r   c                 óR  — |                       |¦  «        \  }}}}|dk    r^|                      dd                     |¦  «        z   ¦  «         |D ].}|                      |d¬¦  «        st	          j        d|¦  «         Œ/d S |dk    r^|                      dd                     |¦  «        z   ¦  «         |D ].}|                      |d¬¦  «        st	          j        d	|¦  «         Œ/d S |d
k    r^|                      dd                     |¦  «        z   ¦  «         |D ].}|                      |d¬¦  «        st	          j        d|¦  «         Œ/d S |dk    r^|                      dd                     |¦  «        z   ¦  «         |D ].}|                      |d¬¦  «        st	          j        d|¦  «         Œ/d S |dk    rb|                      d|›dd                     |¦  «        ›�¦  «         |D ]/}|                      ||¬¦  «        st	          j        d||¦  «         Œ0d S |dk    rb|                      d|›dd                     |¦  «        ›�¦  «         |D ]/}|                      ||¬¦  «        st	          j        d||¦  «         Œ0d S |dk    rH|                      d|z   ¦  «         |                      d |¬¦  «        st	          j        d|¦  «         d S d S |dk    rH|                      d|z   ¦  «         |                      d |¬¦  «        st	          j        d|¦  «         d S d S t          d|z  ¦  «        ‚)Nr6   zinclude ú r/   )Úanchorz%warning: no files found matching '%s'r7   zexclude z9warning: no previously-included files found matching '%s'r8   zglobal-include r   z>warning: no files found matching '%s' anywhere in distributionr9   zglobal-exclude zRwarning: no previously-included files matching '%s' found anywhere in distributionrB   zrecursive-include )Úprefixz:warning: no files found matching '%s' under directory '%s'rC   zrecursive-exclude zNwarning: no previously-included files matching '%s' found under directory '%s'rF   zgraft z+warning: no directories found matching '%s'rG   zprune z6no previously-included directories found matching '%s'z'this cannot happen: invalid action '%s')rM   r   r*   Úinclude_patternr   r   Úexclude_patternr   )r   rH   rJ   rK   r   rL   Úpatterns          r   Úprocess_template_linezFileList.process_template_lineh   si  € ð 04×/HÒ/HÈÑ/NÔ/NÑ,ˆ�˜3 ð
 �YÒÐØ×Ò˜Z¨#¯(ª(°8Ñ*<Ô*<Ñ<Ñ=Ô=Ð=Ø#ð &ð &�Ø×+Ò+¨G¸AÐ+Ñ>Ô>ð &Ý”HÐDØ$ñ&ô &ð &øð&ð &ð
 �yÒ Ð Ø×Ò˜Z¨#¯(ª(°8Ñ*<Ô*<Ñ<Ñ=Ô=Ð=Ø#ð ?ð ?�Ø×+Ò+¨G¸AÐ+Ñ>Ô>ð ?Ý”Hð 4Ø6=ñ?ô ?ð ?øð?ð ?ð
 Ð'Ò'Ð'Ø×ÒÐ.°·²¸(Ñ1CÔ1CÑCÑDÔDÐDØ#ð Dð D�Ø×+Ò+¨G¸AÐ+Ñ>Ô>ð DÝ”Hð 9Ø;BñDô Dð DøðDð Dð
 Ð'Ò'Ð'Ø×ÒÐ.°·²¸(Ñ1CÔ1CÑCÑDÔDÐDØ#ð &ð &�Ø×+Ò+¨G¸AÐ+Ñ>Ô>ð &Ý”Hð Dà$ñ&ô &ð &øð&ð &ð Ð*Ò*Ð*Ø×ÒÐØ!˜c˜c 3§8¢8¨HÑ#5Ô#5Ð#5ð7ñ 8ô 8ð 8à#ð +ð +�Ø×+Ò+¨G¸CÐ+Ñ@Ô@ð +Ý”Hð 7à$ cñ+ô +ð +øð+ð +ð Ð*Ò*Ð*Ø×ÒÐØ!˜c˜c 3§8¢8¨HÑ#5Ô#5Ð#5ð7ñ 8ô 8ð 8à#ð +ð +�Ø×+Ò+¨G¸CÐ+Ñ@Ô@ð +Ý”Hð @à$ cñ+ô +ð +øð+ð +ð �wÒÐØ×Ò˜X¨Ñ3Ñ4Ô4Ð4Ø×'Ò'¨°[Ð'ÑAÔAð &Ý”ÐFØ$ñ&ô &ð &ð &ð &ð&ð &ð �wÒÐØ×Ò˜X¨Ñ3Ñ4Ô4Ð4Ø×'Ò'¨°[Ð'ÑAÔAð 9Ý”ð *Ø,7ñ9ô 9ð 9ð 9ð 9ð9ð 9õ )Ø;¸fÑDñFô Fð Fr   r/   r   c                 óD  — d}t          ||||¦  «        }|                      d|j        z  ¦  «         | j        €|                      ¦   «          | j        D ]K}|                     |¦  «        r4|                      d|z   ¦  «         | j                             |¦  «         d}ŒL|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'%s'Nz adding T)Útranslate_patternr   rT   r   r   Úsearchr   r   )r   rT   rP   rQ   Úis_regexÚfiles_foundÚ
pattern_reÚnames           r   rR   zFileList.include_pattern´   s»   € ð4 ˆÝ& w°¸ÀÑIÔIˆ
Ø×ÒÐ@Ø#Ô+ñ,ñ 	-ô 	-ð 	-ð Œ=Ð Ø�LŠL‰NŒNˆNà”Mð 	#ð 	#ˆDØ× Ò  Ñ&Ô&ð #Ø× Ò  ¨dÑ!2Ñ3Ô3Ð3Ø”
×!Ò! $Ñ'Ô'Ð'Ø"�øØÐr   c                 óT  — d}t          ||||¦  «        }|                      d|j        z  ¦  «         t          t	          | j        ¦  «        dz
  dd¦  «        D ]O}|                     | j        |         ¦  «        r-|                      d| j        |         z   ¦  «         | j        |= d}ŒP|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'%s'r/   r0   z
 removing T)rW   r   rT   r1   r2   r   rX   )r   rT   rP   rQ   rY   rZ   r[   r3   s           r   rS   zFileList.exclude_patternß   sº   € ð ˆÝ& w°¸ÀÑIÔIˆ
Ø×ÒÐ@Ø#Ô+ñ,ñ 	-ô 	-ð 	-å•s˜4œ:‘” qÑ(¨"¨bÑ1Ô1ð 	#ð 	#ˆAØ× Ò  ¤¨A¤Ñ/Ô/ð #Ø× Ò  °´
¸1´Ñ!=Ñ>Ô>Ð>Ø”J˜q�MØ"�øØÐr   )NN©r/   Nr   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r'   Úcurdirr   r   r   r"   r-   r4   rM   rU   rR   rS   r<   r   r   r	   r	      sú   € € € € € ðð ðð ð ð ð!ð !ð !ð œ)ð %ð %ð %ð %ðð ð ð ð  ð  ð!ð !ð !ð9ð 9ð 9ð"ð "ð "ð4ð 4ð 4ð8GFð GFð GFðX(ð (ð (ð (ðX :;ðð ð ð ð ð r   r	   c                 ó€   — d„ t          j        | d¬¦  «        D ¦   «         }t          t           j        j        |¦  «        S )z%
    Find all files under 'path'
    c              3   óh   K  — | ]-\  }}}|D ]$}t           j                             ||¦  «        V — Œ%Œ.d S r   )r'   r(   r*   )r>   ÚbaseÚdirsr   Úfiles        r   ú	<genexpr>z#_find_all_simple.<locals>.<genexpr>ú   sc   è è € ð ð áˆD�$˜Øðð ð õ 	Œ�Š�T˜4Ñ Ô ðð ð ð ð ð ð r   T)Úfollowlinks)r'   ÚwalkÚfilterr(   Úisfile)r(   Úresultss     r   Ú_find_all_simplero   ö   sE   € ðð å!#¤¨¸4Ð!@Ñ!@Ô!@ðñ ô €Gõ
 •"”'”. 'Ñ*Ô*Ð*r   c                 óÈ   — t          | ¦  «        }| t          j        k    r5t          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)	ro   r'   rc   Ú	functoolsÚpartialr(   Úrelpathr&   Úlist)r   r   Úmake_rels      r   r   r     sR   € õ
 ˜SÑ!Ô!€EØ
�bŒiÒÐÝÔ$¥R¤W¤_¸CÐ@Ñ@Ô@ˆÝ�H˜eÑ$Ô$ˆÝ�‰;Œ;Ðr   c                 ó    — t          j        | ¦  «        }t          j        }t          j        dk    rd}d|z  }t	          j        d||¦  «        }|S )zæTranslate 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[^%s]z((?<!\\)(\\\\)*)\.)ÚfnmatchÚ	translater'   ÚsepÚreÚsub)rT   r[   r{   Úescapeds       r   Ú
glob_to_rer     sS   € õ Ô" 7Ñ+Ô+€Jõ Œ&€CÝ	„v�‚~€~ð ˆØ˜3Ñ€GÝ”Ð-¨w¸
ÑCÔC€JØÐr   r/   c                 ó0  — |r+t          | t          ¦  «        rt          j        | ¦  «        S | S t	          d¦  «                             d¦  «        \  }}}| r<t	          | ¦  «        }|                     |¦  «        r|                     |¦  «        sJ ‚nd}|�Ðt	          |¦  «        }|                     |¦  «        r|                     |¦  «        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).
    Ú_Ú Nrx   z\\z\Az.*)Ú
isinstanceÚstrr|   Úcompiler   Ú	partitionÚ
startswithÚendswithr2   r'   r{   )
rT   rP   rQ   rY   rq   r�   Úendr[   Ú	prefix_rer{   s
             r   rW   rW   %  sš  € ð ð Ý�g�sÑ#Ô#ð 	Ý”:˜gÑ&Ô&Ð&àˆNõ ˜s‘O”O×-Ò-¨cÑ2Ô2�M€Eˆ1ˆcàð Ý Ñ(Ô(ˆ
Ø×$Ò$ UÑ+Ô+ÐH°
×0CÒ0CÀCÑ0HÔ0HÐHÐHÐHÐHàˆ
àÐÝ˜vÑ&Ô&ˆ	Ø×#Ò# EÑ*Ô*ÐF¨y×/AÒ/AÀ#Ñ/FÔ/FÐFÐFÐFØ�c %™jœj­#¨i©.¬.½3¸s¹8¼8Ñ*CÐCÔDˆ	ÝŒfˆÝŒ6�TŠ>ˆ>ØˆCØ¥ E¡
¤
­C°
©O¬O½cÀ#¹h¼hÑ,FÐ FÔGˆ
Ø*/¨%¨%°°¸C¸C¸CÀÀÈSÈSÐQˆ
ˆ
àð 	FØ&+ e e¨Z½¸E¹
¼
¸¸Ô-DÐ-DÐEˆJåŒ:�jÑ!Ô!Ð!r   r^   )rb   r'   r|   ry   rr   Údistutils.utilr   Údistutils.errorsr   r   Ú	distutilsr   r	   ro   rc   r   r   rW   r<   r   r   ú<module>rŽ      sû   ððð ð €€€€€€€Ø €€€Ø Ð Ð Ð Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø KÐ KÐ KÐ KÐ KÐ KÐ KÐ KØ Ð Ð Ð Ð Ð ðbð bð bð bð bñ bô bð bðP	+ð 	+ð 	+ð ”	ð 	ð 	ð 	ð 	ðð ð ð.""ð ""ð ""ð ""ð ""ð ""r   