
    q"hX7                     @   S r SSK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	  SSK
Jr  S/r\R                  " \5      r\R                   " S\R"                  5      r\R                   " S	\R"                  \R&                  -  5      r\R*                  SS
 r " S S\5      rg)zu
Class representing the list of files in a distribution.

Equivalent to distutils.filelist, but fixes some problems.
    N   )DistlibException)fsdecode)convert_pathManifestz\\w*
z#.*?(?=
)|
(?=$)   c                       \ rS rSrSrSS jrS rS rS rSS jr	S	 r
S
 rS r  SS jr  SS jr  SS jrS rSrg)r   &   zt
A list of files built by exploring the filesystem and filtered by applying various
patterns to what we find there.
Nc                 .   [         R                  R                  [         R                  R                  U=(       d    [         R                  " 5       5      5      U l        U R
                  [         R                  -   U l        SU l        [        5       U l
        g)zL
Initialise an instance.

:param base: The base directory to explore under.
N)ospathabspathnormpathgetcwdbasesepprefixallfilessetfiles)selfr   s     N/var/www/html/env/lib/python3.13/site-packages/pip/_vendor/distlib/manifest.py__init__Manifest.__init__,   sV     GGOOBGG$4$4T5HRYY[$IJ	ii"&&(U
    c                    SSK JnJnJn  / =U l        nU R
                  nU/nUR                  nUR                  nU(       a  U" 5       n[        R                  " U5      n	U	 H  n
[        R                  R                  XZ5      n[        R                   " U5      nUR                  nU" U5      (       a  UR                  [        U5      5        Mm  U" U5      (       d  M|  U" U5      (       a  M  U" U5        M     U(       a  M  gg)z]Find all files under the base and set ``allfiles`` to the absolute
pathnames of files found.
r   )S_ISREGS_ISDIRS_ISLNKN)statr   r   r   r   r   popappendr   listdirr   joinst_moder   )r   r   r   r   r   rootstackr!   pushnamesnamefullnamer    modes                 r   findallManifest.findall;   s     	32#%%yyii||5DJJt$E77<<3 wwx(||4==OOHX$67T]]74==N 	 er   c                    UR                  U R                  5      (       d*  [        R                  R	                  U R
                  U5      nU R                  R                  [        R                  R                  U5      5        g)zb
Add a file to the manifest.

:param item: The pathname to add. This can be relative to the base.
N)	
startswithr   r   r   r$   r   r   addr   )r   items     r   r1   Manifest.addV   sN     t{{++77<<		40D

rww''-.r   c                 8    U H  nU R                  U5        M     g)zn
Add a list of files to the manifest.

:param items: The pathnames to add. These can be relative to the base.
N)r1   )r   itemsr2   s      r   add_manyManifest.add_many`   s     DHHTN r   c                 L  ^ ^ UU 4S jm[        T R                  5      nU(       a=  [        5       nU H)  nT" U[        R                  R	                  U5      5        M+     X#-  n[        S U 5       5       Vs/ s H   n[        R                  R                  " U6 PM"     sn$ s  snf )z(
Return sorted files in directory order
c                    > U R                  U5        [        R                  SU5        UTR                  :w  a2  [        R
                  R                  U5      u  p#US;  d   eT" X5        g g )Nzadd_dir added %s) /)r1   loggerdebugr   r   r   split)dirsdparent_add_dirr   s       r   rC    Manifest.sorted.<locals>.add_dirn   sW    HHQKLL+Q/DII~GGMM!,	Y...% r   c              3   `   #    U  H$  n[         R                  R                  U5      v   M&     g 7fN)r   r   r>   ).0r   s     r   	<genexpr>"Manifest.sorted.<locals>.<genexpr>}   s      >vtrww}}T**vs   ,.)r   r   r   r   dirnamesortedr$   )r   wantdirsresultr?   f
path_tuplerC   s   `     @r   rK   Manifest.sortedi   s    
	& TZZ5Dbggooa01 NF>v>>@> /9j)>@ 	@ @s   7'B!c                 0    [        5       U l        / U l        g)zClear all collected files.N)r   r   r   )r   s    r   clearManifest.clear   s    U
r   c                 <   U R                  U5      u  p#pEUS:X  a7  U H0  nU R                  USS9(       a  M  [        R                  SU5        M2     gUS:X  a  U H  nU R	                  USS9  M     gUS:X  a7  U H0  nU R                  USS9(       a  M  [        R                  SU5        M2     gUS	:X  a  U H  nU R	                  USS9  M     gUS
:X  a6  U H/  nU R                  XdS9(       a  M  [        R                  SXd5        M1     gUS:X  a  U H  nU R	                  XdS9  M     gUS:X  a-  U R                  SUS9(       d  [        R                  SU5        ggUS:X  a-  U R	                  SUS9(       d  [        R                  SU5        gg[        SU-  5      e)aF  
Process a directive which either adds some files from ``allfiles`` to
``files``, or removes some files from ``files``.

:param directive: The directive to process. This should be in a format
             compatible with distutils ``MANIFEST.in`` files:

             http://docs.python.org/distutils/sourcedist.html#commands
includeT)anchorzno files found matching %rexcludeglobal-includeFz3no files found matching %r anywhere in distributionglobal-excluderecursive-include)r   z-no files found matching %r under directory %rrecursive-excludegraftNz no directories found matching %rprunez4no previously-included directories found matching %rzinvalid action %r)_parse_directive_include_patternr<   warning_exclude_patternr   )r   	directiveactionpatternsthedir
dirpatternpatterns          r   process_directiveManifest.process_directive   s    04/D/DY/O,&
 Y#,,WT,BBNN#?I $ y #%%gd%; $ ''#,,WU,CCNN $>?FH $
 ''#%%ge%< $ **#,,W,DDNN $89@J $
 **#%%g%= $ w((j(AA)+ B w((j(A  -.8: B ##f,. .r   c                 J   UR                  5       n[        U5      S:X  a  US   S;  a  UR                  SS5        US   nS=n=pVUS;   a<  [        U5      S:  a  [        SU-  5      eUSS  Vs/ s H  n[	        U5      PM     nnOUS	;   aJ  [        U5      S
:  a  [        SU-  5      e[	        US   5      nUSS  Vs/ s H  n[	        U5      PM     nnO@US;   a,  [        U5      S:w  a  [        SU-  5      e[	        US   5      nO[        SU-  5      eX4XV4$ s  snf s  snf )z
Validate a directive.
:param directive: The directive to validate.
:return: A tuple of action, patterns, thedir, dir_patterns
r   r   )rU   rW   rX   rY   rZ   r[   r\   r]   rU   N)rU   rW   rX   rY   r   z$%r expects <pattern1> <pattern2> ...)rZ   r[      z*%r expects <dir> <pattern1> <pattern2> ...)r\   r]   z!%r expects a single <dir_pattern>zunknown action %r)r>   leninsertr   r   )r   rb   wordsrc   rd   re   dir_patternwords           r   r^   Manifest._parse_directive   sf    !u:?uQx 0B  B LLI&q*...6 : :5zA~&:VCE E 8=QRyAytT*yHAHAA5zA~&@6IK K "%(+F7<QRyAytT*yHAH))5zQ&7&@B B 'uQx0K ##6#?@@44) B Bs   /D?D c                     SnU R                  XX45      nU R                  c  U R                  5         U R                   H8  nUR                  U5      (       d  M  U R                  R                  U5        SnM:     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.
FT)_translate_patternr   r-   searchr   r1   )r   rg   rV   r   is_regexfound
pattern_rer*   s           r   r_   Manifest._include_pattern   sk    8 ,,WfO
 == LLNMMD  &&

t$ " r   c                     SnU R                  XX45      n[        U R                  5       H8  nUR                  U5      (       d  M  U R                  R	                  U5        SnM:     U$ )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.

This API is public to allow e.g. exclusion of SCM subdirs, e.g. when
packaging source distributions
FT)rs   listr   rt   remove)r   rg   rV   r   ru   rv   rw   rN   s           r   ra   Manifest._exclude_pattern   s]     ,,WfO
djj!A  ##

!!!$ " r   c                    U(       a-  [        U[        5      (       a  [        R                  " U5      $ U$ [        S:  a#  U R                  S5      R                  S5      u  pVnU(       aJ  U R                  U5      n[        S:  a.  UR                  W5      (       a  UR                  W5      (       d   eOSn[        R                  " [        R                  R                  U R                  S5      5      n	UGb"  [        S::  a0  U R                  S5      n
U R                  U5      S[        U
5      *  nObU R                  U5      nUR                  W5      (       a  UR                  W5      (       d   eU[        U5      [        U5      [        U5      -
   n[        R                  n[        R                  S:X  a  Sn[        S::  a  SU	-   UR                  USU-   45      -   nOjU[        W5      [        U5      [        W5      -
   nU< U	< U< U< SU< U< 3nO1U(       a*  [        S::  a	  SU	-   U-   nOW< U	< 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).
)rk   r   rB   r:   N\z\\^z.*)
isinstancestrrecompile_PYTHON_VERSION_glob_to_re	partitionr0   endswithescaper   r   r$   r   rl   r   )r   rg   rV   r   ru   startrB   endrw   r   empty_pattern	prefix_rer   s                r   rs   Manifest._translate_pattern4  s    '3''zz'**V# ,,S1;;C@MEc))'2J'!,,U33
8K8KC8P8PPPJyydii45&( $ 0 0 4 ,,V45Is=7I6IJ	 ,,V4	 ++E22y7I7I#7N7NNN%c%j#i.3s82KL	&&Cvv~&( 4Z#((I48:4E4G +H H
 (E
C
Oc#h4NO
27y#2<cC
 "f,!$tj!8J.3T:c%jk;R!SJzz*%%r   c                     [         R                  " U5      n[        R                  n[        R                  S:X  a  SnSU-  n[        R
                  " SXB5      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).
r~   z\\\\z\1[^%s]z((?<!\\)(\\\\)*)\.)fnmatch	translater   r   r   sub)r   rg   rw   r   escapeds        r   r   Manifest._glob_to_rek  sR     &&w/
 ff66T> Cs"VV17G
r   )r   r   r   r   rF   )F)TNF)__name__
__module____qualname____firstlineno____doc__r   r-   r1   r6   rK   rR   rh   r^   r_   ra   rs   r   __static_attributes__ r   r   r   r   &   sc    
	#6/@,
>.H-5^ =A"''R =A"'( ?C$)5&nr   )r   r   loggingr   r   sysr:   r   compatr   utilr   __all__	getLoggerr   r<   r   M_COLLAPSE_PATTERNS_COMMENTED_LINEversion_infor   objectr   r   r   r   <module>r      s   
   	 	 
    ,			8	$ JJz2440 **1244"$$;? ""2A&Zv Zr   