
    Kxh9                        d Z ddl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	 ddl
mZ dgZ ej        e          Z ej        dej                  Z ej        d	ej        ej        z            Zej        dd
         Z G d de          ZdS )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                   p    e Zd ZdZddZd Zd Zd ZddZd	 Z	d
 Z
d Z	 	 ddZ	 	 ddZ	 	 ddZd ZdS )r   z~A list of files built by on exploring the filesystem and filtered by
    applying various patterns to what we find there.
    Nc                    t           j                            t           j                            |pt          j                                        | _        | j        t           j        z   | _        d| _        t                      | _
        dS )zd
        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     O/var/www/html/what/lib/python3.11/site-packages/pip/_vendor/distlib/manifest.py__init__zManifest.__init__*   sZ     GOOBG$4$4T5HRY[[$I$IJJ	i"&(UU


    c                    ddl m}m}m} g x| _        }| j        }|g}|j        }|j        }|r |            }t          j	        |          }	|	D ]}
t          j
                            ||
          }t          j         |          }|j        } ||          r#|                    t          |                     k ||          r ||          s ||           |dS dS )zmFind 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   findallzManifest.findall9   s     	3222222222#%%yi| 	#355DJt$$E 	# 	#7<<d33 wx((|74== #OOHX$6$67777WT]] #774== #DNNN  	# 	# 	# 	# 	#r   c                     |                     | j                  s%t          j                            | j        |          }| j                            t          j                            |                     dS )zz
        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   r/   zManifest.addT   s[     t{++ 	17<<	400D
rw''--.....r   c                 :    |D ]}|                      |           dS )z
        Add a list of files to the manifest.

        :param items: The pathnames to add. These can be relative to the base.
        N)r/   )r   itemsr0   s      r   add_manyzManifest.add_many^   s.      	 	DHHTNNNN	 	r   Fc                      fdt           j                  }|rAt                      }|D ]+} |t          j                            |                     ,||z  }d t          d |D                       D             S )z8
        Return sorted files in directory order
        c                     |                      |           t                              d|           |j        k    r6t          j                            |          \  }}|dvsJ  | |           d S d S )Nzadd_dir added %s) /)r/   loggerdebugr   r   r   split)dirsdparent_add_dirr   s       r   r?   z Manifest.sorted.<locals>.add_dirl   sy    HHQKKKLL+Q///DI~~GMM!,,	Y....f%%%%% ~r   c                 4    g | ]}t          j        j        | S  )r   r   r#   ).0
path_tuples     r   
<listcomp>z#Manifest.sorted.<locals>.<listcomp>z   s3     @ @ @jj) @ @ @r   c              3   T   K   | ]#}t           j                            |          V  $d S N)r   r   r:   )rB   r   s     r   	<genexpr>z"Manifest.sorted.<locals>.<genexpr>{   s0      >>trw}}T**>>>>>>r   )r   r   r   r   dirnamesorted)r   wantdirsresultr;   fr?   s   `    @r   rI   zManifest.sortedg   s    
	& 	& 	& 	& 	& 	& TZ 	55D 2 2bgooa001111dNF@ @>>v>>>>>@ @ @ 	@r   c                 :    t                      | _        g | _        dS )zClear all collected files.N)r   r   r   )r   s    r   clearzManifest.clear}   s    UU
r   c                    |                      |          \  }}}}|dk    r9|D ]4}|                     |d          st                              d|           5dS |dk    r|D ]}|                     |d          }dS |dk    r9|D ]4}|                     |d          st                              d|           5dS |d	k    r|D ]}|                     |d          }dS |d
k    r:|D ]5}|                     ||          st                              d||           6dS |dk    r|D ]}|                     ||          }dS |dk    r6|                     d|          st                              d|           dS dS |dk    r6|                     d|          st                              d|           dS dS t          d|z            )av  
        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_patternr8   warning_exclude_patternr   )r   	directiveactionpatternsthedir
dirpatternpatternfounds           r   process_directivezManifest.process_directive   s    04/D/DY/O/O,&*
 Y# J J,,WT,BB JNN#?IIIJ J y  # D D--gd-CCD D '''# H H,,WU,CC HNN $>?FH H HH H
 '''# E E--ge-DDE E ***# J J,,WV,DD JNN $89@&J J JJ J
 ***# F F--gf-EEF F w((j(AA +A)+ + + + ++ + w((j(AA :  -.8: : : : :: : ##f,. . .r   c                 |   |                                 }t          |          dk    r |d         dvr|                    dd           |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 )z
        Validate a directive.
        :param directive: The directive to validate.
        :return: A tuple of action, patterns, thedir, dir_patterns
        r   r   )rP   rR   rS   rT   rU   rV   rW   rX   rP   N)rP   rR   rS   rT   r	   z$%r expects <pattern1> <pattern2> ...c                 ,    g | ]}t          |          S rA   r   rB   words     r   rD   z-Manifest._parse_directive.<locals>.<listcomp>        AAAtT**AAAr   )rU   rV      z*%r expects <dir> <pattern1> <pattern2> ...c                 ,    g | ]}t          |          S rA   r   rg   s     r   rD   z-Manifest._parse_directive.<locals>.<listcomp>   ri   r   )rW   rX   z!%r expects a single <dir_pattern>zunknown action %r)r:   leninsertr   r   )r   r]   wordsr^   r_   r`   dir_patterns          r   rY   zManifest._parse_directive   s    !!u::??uQx 0B  B  B LLI&&&q*...6K : : :5zzA~~&:VCE E E BAuQRRyAAAHHAAA5zzA~~&@6IK K K "%(++FAAuQRRyAAAHH)))5zzQ&7&@B B B 'uQx00KK ##6#?@@@x44r   Tc                     d}|                      ||||          }| j        |                                  | j        D ]3}|                    |          r| j                            |           d}4|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.
        FNT)_translate_patternr   r,   searchr   r/   )r   rb   rQ   r   is_regexrc   
pattern_rer)   s           r   rZ   zManifest._include_pattern   s    8 ,,WffhOO
 = LLNNNM 	 	D  && 
t$$$r   c                     d}|                      ||||          }t          | j                  D ]3}|                    |          r| j                            |           d}4|S )at  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)rq   listr   rr   remove)r   rb   rQ   r   rs   rc   rt   rL   s           r   r\   zManifest._exclude_pattern)  sr     ,,WffhOO
dj!! 	 	A  ## 
!!!$$$r   c                    |r+t          |t                    rt          j        |          S |S t          dk    r,|                     d                              d          \  }}}|rM|                     |          }t          dk    r,|                    |          r|                    |          sJ nd}t          j	        t          j                            | j        d                    }	|Ot          dk    rA|                     d          }
|                     |          dt          |
                    }nu|                     |          }|                    |          r|                    |          sJ |t          |          t          |          t          |          z
           }t          j        }t          j        dk    rd}t          dk    r!d|	z   |                    |d|z   f          z   }nw|t          |          t          |          t          |          z
           }||	||d||}n3|r1t          dk    r	d|	z   |z   }n||	|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).
        )rj   r	   r>   r6   N\z\\^z.*)
isinstancestrrecompile_PYTHON_VERSION_glob_to_re	partitionr.   endswithescaper   r   r#   r   rl   r   )r   rb   rQ   r   rs   startr>   endrt   r   empty_pattern	prefix_rer   s                r   rq   zManifest._translate_pattern=  s     	'3'' z'***V## ,,S11;;C@@ME1c 	))'22J''!,,U33P
8K8KC8P8PPPPJydi4455&(( $ 0 0 4 4 ,,V445Is=7I7I6I5IJ		 ,,V44	 ++E22Ny7I7I#7N7NNNN%c%jj#i..3s882K&KL	&Cv~~&(( 4Z#((I48:4E4G +H +H H

 (E

C
OOc#hh4N(NO
27%yy###2<*ccC

  T"f,,!$tj!8JJ.3eTT:c%jjkk;R;R!SJz*%%%r   c                     t          j        |          }t          j        }t          j        dk    rd}d|z  }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).
        ry   z\\\\z\1[^%s]z((?<!\\)(\\\\)*)\.)fnmatch	translater   r   r}   sub)r   rb   rt   r   escapeds        r   r   zManifest._glob_to_ret  sS     &w//
 f6T>> Cs"V17JGG
r   rF   )F)TNF)__name__
__module____qualname____doc__r   r,   r/   r3   rI   rN   rd   rY   rZ   r\   rq   r   rA   r   r   r   r   %   s        	 	 	 	# # #6/ / /  @ @ @ @,  
I. I. I.^-5 -5 -5^ =A"'' ' ' 'R =A"'   ( ?C$)5& 5& 5& 5&n    r   )r   r   loggingr   r}   sysr6   r   compatr   utilr   __all__	getLoggerr   r8   r~   M_COLLAPSE_PATTERNS_COMMENTED_LINEversion_infor   objectr   rA   r   r   <module>r      s   
   				 				 



                   ,		8	$	$ BJz2400 "*124"$;?? "2A2&d d d d dv d d d d dr   