Ë
    ¨Õ°j/<  ã                  óÖ   — 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      úT/var/www/mission/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   € ä¤¤B§G¡G§M¡M°4·:±:Ó >Ó?ˆØˆŒ
Ø(ò 	9ˆJØ�J‰J×ÑœbŸg™gŸl™l¨JÐ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   € ä”s˜4Ÿ:™:“¨Ñ*¨A¨rÓ2ò 	"ˆAØ�z‰z˜!‰} §
¡
¨1¨q©5Ñ 1Ó1Ø—J‘J˜q‘Mñ	"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Ü�5‹z˜AŠ~Ü,Ø˜�xÐBÐCóð ð 27°q°r°Ö;¨Aœ Q�Ð;ˆHÑ;ØÐAÑAÜ�5‹z˜AŠ~Ü,Ø˜�xÐHÐIóð ô ˜u Q™xÓ(ˆCØ16°q°r°Ö;¨Aœ Q�Ð;ˆHÑ;ØÐ)Ñ)Ü�5‹z˜QŠÜ,Ø˜�xÐ?Ð@óð ô ' u¨Q¡xÓ0‰Kä(Ð+;¸F¸8À1Ð)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�Ø×+Ñ+¨G¸DÐ+ÕAÜ—K‘KÐ GÈÕQñRð �yÒ Ø×Ñ˜Z¨#¯(©(°8Ó*<Ñ<Ô=Ø#ò �Ø×+Ñ+¨G¸DÐ+ÕAÜ—K‘KØSØõñð Ð'Ò'Ø×ÑÐ.°·±¸(Ó1CÑCÔDØ#ò �Ø×+Ñ+¨G¸EÐ+ÕBÜ—K‘Kð7ð  õñð Ð'Ò'Ø×ÑÐ.°·±¸(Ó1CÑCÔDØ#ò �Ø×+Ñ+¨G¸EÐ+ÕBÜ—K‘KðBð  õñð Ð*Ò*Ø×ÑÐ6×=Ñ=¸cÀ3Ç8Á8ÈHÓCUÓVÔWØ#ò 3�Ø×+Ñ+¨G¸CÐ+Õ@ØV�CÜ—K‘K  W¨cÕ2ñ3ð
 Ð*Ò*Ø×ÑÐ6×=Ñ=¸cÀ3Ç8Á8ÈHÓCUÓVÔWØ#ò 	�Ø×+Ñ+¨G¸CÐ+Õ@Ü—K‘Kð>ð  Øõñ	ð �wÒØ×Ñ˜X¨Ñ3Ô4Ø×'Ñ'¨°[Ð'ÔAÜ—‘ÐIÈ;ÕWð Bð �wÒØ×Ñ˜X¨Ñ3Ô4Ø×'Ñ'¨°[Ð'ÔAÜ—‘ØMØõð Bô )Ø6°v°h¸aÐ@óð 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}t        ||||«      }| j                  d|j                  › d�«       | j                  €| j	                  «        | 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Ð=QÐQRÐSÔTð �=‰=Ð Ø�L‰LŒNØ�}‰}Ð(Ð(Ð(à—M‘Mò 	#ˆ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Ð=QÐQRÐSÔTÜ”s˜4Ÿ:™:“¨Ñ*¨B°Ó3ò 	#ˆAØ× Ñ  §¡¨A¡Õ/Ø× Ñ  °·
±
¸1±Ñ!=Ô>Ø—J‘J˜q�MØ"‘ð		#ð
 Ð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   ú
str | NonerM   ÚboolrN   rn   rX   zLiteral[False]rh   ro   )TN)
rS   zstr | re.Pattern[str]rM   ro   rN   rn   rX   zLiteral[True]rh   ro   )
rS   zstr | re.Pattern | NonerM   ro   rN   rn   rX   ro   rh   ro   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r+   Úcurdirr   r   r#   r&   r1   r7   rJ   rT   r   rO   rQ   rV   r   r   r   r      sƒ  „ ñô#ó!ð 57·I±Iô %óó ó!ó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>J  s=   è ø€ ò Ù%6 T¨4°ÐQVòØIMŒ�‰�‰�T˜4× ðØ ñùs   ‚57)Ú_UniqueDirsÚfilterr+   Úwalkr,   Úisfile)r,   Ú
all_uniqueÚresultss      r   Ú_find_all_simplerƒ   E  sE   € ô ×#Ñ#¤B§G¡G¨D¸dÔ$CÓD€JñØ: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   Ú_filesr†   Ú	candidateÚfounds           r   Ú__call__z_UniqueDirs.__call__W  sW   € ð 'Ñˆˆd�FÜ�w‰w�t‹}ˆØ—K‘K §¡Ð,ˆ	Ø˜TÐ!ˆÙØ’Q�Ø�‰�ÔØˆyÐr   c                ó$   — t         | «       |«      S r   )r~   )Úclsr'   s     r   r~   z_UniqueDirs.filterf  s   € ä‘c“e˜UÓ#Ð#r   N)rp   rq   rr   rs   rŽ   Úclassmethodr~   rV   r   r   r}   r}   P  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   k  sJ   € ô
 ˜SÓ!€EØ
Œb�i‰iÒÜ×$Ñ$¤R§W¡W§_¡_¸CÔ@ˆÜ�H˜eÓ$ˆÜ�‹;Ðr   c                ó´   — t        j                  | «      }t        j                  }t        j                  dk(  rd}d|› d�}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[^ú]z((?<!\\)(\\\\)*)\.)ÚfnmatchÚ	translater+   ÚsepÚreÚsub)rS   ra   rž   Úescapeds       r   Ú
glob_to_rer¢   w  sW   € ô ×"Ñ" 7Ó+€Jô �&‰&€CÜ	‡v�v�‚~ð ˆØ�c�U˜!ˆn€GÜ—‘Ð-¨w¸
ÓC€JØÐ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^   Ž  sD  € ñ Ü�gœsÔ#Ü—:‘:˜gÓ&Ð&àˆNô ˜s“O×-Ñ-¨cÓ2�M€Eˆ1ˆcáÜ Ó(ˆ
Ø×$Ñ$ UÔ+°
×0CÑ0CÀCÔ0HÐHÐHàˆ
àÐÜ˜vÓ&ˆ	Ø×#Ñ# EÔ*¨y×/AÑ/AÀ#Ô/FÐFÐFØœc %›j¬3¨y«>¼CÀ»HÑ+DÐEˆ	Ü�f‰fˆÜ�6‰6�TŠ>ØˆCØ¤ E£
¬S°«_¼sÀ3»xÑ-GÐHˆ
Ø˜˜r ) ¨S¨E°°J°<À¸uÐE‰
áØ"˜G 2 j´°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Ý ÷jñ jò`	+ô$�#ô $ð6 +-¯)©)ô 	òô.""r   