
    *,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y)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                   n    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y)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                  j                  t         j                  j                  |xs t        j                                     | _        | j
                  t         j                  z   | _        d| _        t               | _
        y)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     ^/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/pip/_vendor/distlib/manifest.py__init__zManifest.__init__*   sV     GGOOBGG$4$4T5HRYY[$IJ	ii"&&(U
    c                    ddl m}m}m} g x| _        }| j
                  }|g}|j                  }|j                  }|r |       }t        j                  |      }	|	D ]  }
t        j                  j                  ||
      }t        j                   |      }|j                  } ||      r|j                  t        |             g ||      sp ||      ry ||        |ryy)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#%%yyii||5DJJt$E 	#77<<d3 wwx(||4=OOHX$67T]74=N	#	 r   c                     |j                  | j                        s*t        j                  j	                  | j
                  |      }| j                  j                  t        j                  j                  |             y)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   sK     t{{+77<<		40D

rww''-.r   c                 4    |D ]  }| j                  |        y)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   itemsr/   s      r   add_manyzManifest.add_many^   s      	DHHTN	r   c                 6     fdt         j                        }|r<t               }|D ](  } |t        j                  j	                  |             * ||z  }t        d |D              D cg c]  }t        j                  j                  |   c}S c c}w )z8
        Return sorted files in directory order
        c                     | j                  |       t        j                  d|       |j                  k7  r2t        j
                  j                  |      \  }}|dvsJ  | |       y y )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   sX    HHQKLL+Q/DII~GGMM!,	Y..f% r   c              3   Z   K   | ]#  }t         j                  j                  |       % y wN)r   r   r9   ).0r   s     r   	<genexpr>z"Manifest.sorted.<locals>.<genexpr>{   s     >trww}}T*>s   )+)r   r   r   r   dirnamesortedr"   )r   wantdirsresultr:   f
path_tupler>   s   `     @r   rD   zManifest.sortedg   s    
	& TZZ5D 2bggooa012dNF>v>>@jj) @ 	@ @s   0#Bc                 0    t               | _        g | _        y)zClear all collected files.N)r   r   r   )r   s    r   clearzManifest.clear}   s    U
r   c                    | j                  |      \  }}}}|dk(  r2|D ],  }| j                  |d      rt        j                  d|       . y|dk(  r|D ]  }| j	                  |d      } y|dk(  r2|D ],  }| j                  |d      rt        j                  d|       . y|d	k(  r|D ]  }| j	                  |d      } y|d
k(  r3|D ]-  }| j                  ||      rt        j                  d||       / y|dk(  r|D ]  }| j	                  ||      } y|dk(  r+| j                  d|      st        j                  d|       yy|dk(  r+| j	                  d|      st        j                  d|       yy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_patternr7   warning_exclude_patternr   )r   	directiveactionpatternsthedir
dirpatternpatternfounds           r   process_directivezManifest.process_directive   s    04/D/DY/O,&*
 Y# J,,WT,BNN#?IJ y # D--gd-CD ''# H,,WU,CNN $>?FHH
 ''# E--ge-DE **# J,,WV,DNN $89@&JJ
 **# F--gf-EF w((j(AA)+ B w((j(A  -.8: B ##f,. .r   c                 ,   |j                         }t        |      dk(  r|d   dvr|j                  dd       |d   }dx}x}}|dv r8t        |      dk  rt        d|z        |dd D cg c]  }t	        |       }}n|d	v rFt        |      d
k  rt        d|z        t	        |d         }|dd D cg c]  }t	        |       }}n=|dv r+t        |      dk7  rt        d|z        t	        |d         }nt        d|z        ||||fS c c}w c c}w )z
        Validate a directive.
        :param directive: The directive to validate.
        :return: A tuple of action, patterns, thedir, dir_patterns
        r   r   )rL   rN   rO   rP   rQ   rR   rS   rT   rL   N)rL   rN   rO   rP   r   z$%r expects <pattern1> <pattern2> ...)rQ   rR      z*%r expects <dir> <pattern1> <pattern2> ...)rS   rT   z!%r expects a single <dir_pattern>zunknown action %r)r9   leninsertr   r   )r   rY   wordsrZ   r[   r\   dir_patternwords           r   rU   zManifest._parse_directive   sf    !u:?uQx 0B  B LLI&q*...6K : :5zA~&:VCE E 8=QRyAtT*AHAAA5zA~&@6IK K "%(+F7<QRyAtT*AHA))5zQ&7&@B B 'uQx0K ##6#?@@x44) B Bs   *D4Dc                     d}| j                  ||||      }| j                  | j                          | j                  D ]1  }|j                  |      s| j                  j                  |       d}3 |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.
        FT)_translate_patternr   r+   searchr   r.   )r   r^   rM   r   is_regexr_   
pattern_rer(   s           r   rV   zManifest._include_pattern   sq    8 ,,WffhO
 == LLNMM 	D  &

t$	 r   c                     d}| j                  ||||      }t        | j                        D ]1  }|j                  |      s| j                  j	                  |       d}3 |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)ri   listr   rj   remove)r   r^   rM   r   rk   r_   rl   rG   s           r   rX   zManifest._exclude_pattern)  sc     ,,WffhO
djj! 	A  #

!!!$	 r   c                 J   |r't        |t              rt        j                  |      S |S t        dkD  r$| j                  d      j                  d      \  }}}|r>| j                  |      }t        dkD  r&|j                        r|j                        sJ d}t        j                  t        j                  j                  | j                  d            }	|t        dk  r0| j                  d      }
| j                  |      dt        |
        }nX| j                  |      }|j                        r|j                        sJ |t        |      t        |      t        |      z
   }t        j                  }t        j                  dk(  rd}t        dk  rd|	z   |j                  |d|z   f      z   }n[|t              t        |      t              z
   }||	||d||}n(|r&t        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).
        )rb   r   r=   r5   N\z\\^z.*)
isinstancestrrecompile_PYTHON_VERSION_glob_to_re	partitionr-   endswithescaper   r   r"   r   rc   r   )r   r^   rM   r   rk   startr=   endrl   r   empty_pattern	prefix_rer   s                r   ri   zManifest._translate_pattern=  s    '3'zz'**V# ,,S1;;C@ME1c))'2J'!,,U3
8K8KC8PPJyydii45&( $ 0 0 4 ,,V45Is=7I6IJ	 ,,V4	 ++E2y7I7I#7N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                     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).
        rq   z\\\\z\1[^%s]z((?<!\\)(\\\\)*)\.)fnmatch	translater   r   ru   sub)r   r^   rl   r   escapeds        r   rx   zManifest._glob_to_ret  sT     &&w/
 ff66T> Cs"VV17JG
r   r@   )F)TNF)__name__
__module____qualname____doc__r   r+   r.   r2   rD   rJ   r`   rU   rV   rX   ri   rx    r   r   r   r   %   sd    	#6/@,
I.^-5^ =A"''R =A"'( ?C$)5&nr   )r   r   loggingr   ru   sysr5   r   compatr   utilr   __all__	getLoggerr   r7   rv   M_COLLAPSE_PATTERNS_COMMENTED_LINEversion_inforw   objectr   r   r   r   <module>r      s   
   	 	 
    ,			8	$ BJJz2440 "**1244"$$;? ""2A&dv dr   