î
“Re¹4 ã @ sÉ 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 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 Bƒ Z Gd
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 @ sÇ e Z d Z d Z d d d „ Z d d „ Z d d „ Z d d
„ Z d d d
„ Z d d „ Z d d „ Z
d d „ Z d d d d d „ Z d d d d d „ Z
d d d d d „ Z d 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 C sY t j j t j j | p! t j ƒ ƒ ƒ | _ | j t j | _ 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 © r ú7/tmp/pip-ztkk0jow-build/pip/_vendor/distlib/manifest.pyÚ__init__# s - zManifest.__init__c C sü d d l m } m } m } g | _ } | j } | g } | j } | j } x¨ | r÷ | ƒ } t j | ƒ } xƒ | D]{ }
t j
j | |
ƒ } t j | ƒ } | j }
| |
ƒ rÊ | j t
| ƒ ƒ qu | |
ƒ ru | |
ƒ ru | | ƒ qu qu WqP Wd 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 Úmoder r r Úfindall2 s"
zManifest.findallc C sM | j | j ƒ s- t j j | j | ƒ } n | j j t j 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 Úitemr r r r( M s zManifest.addc C s" x | D] } | j | ƒ q Wd 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 Úitemsr) r r r Úadd_manyW s
zManifest.add_manyFc sŽ ‡ ‡ f d d † ‰ t ˆ j ƒ } | rj t ƒ } x' | D] } ˆ | t j j | ƒ ƒ q: W| | O} n d d „ t d d „ | Dƒ ƒ Dƒ S)z8
Return sorted files in directory order
c sj | j | ƒ t j d | ƒ | ˆ j k rf t j j | ƒ \ } } | d k sV t ‚ ˆ | | ƒ n d S)Nzadd_dir added %sÚ ú/)r, r- )r( ÚloggerÚdebugr r r ÚsplitÚAssertionError)ÚdirsÚdÚparentÚ_)Úadd_dirr r r r6 e s
z Manifest.sorted..add_dirc S s" g | ] } t j j | Œ ‘ q Sr )r r r )Ú.0Z
path_tupler r r ú
s s z#Manifest.sorted..c s s! | ] } t j j | ƒ Vq d S)N)r r r0 )r7 r r r r ú t s z"Manifest.sorted..)r r r r ÚdirnameÚsorted)r ZwantdirsÚresultr2 Úfr )r6 r r r; ` s
zManifest.sortedc C s t ƒ | _ g | _ d S)zClear all collected files.N)r r r )r r r r Úclearv s zManifest.clearc C sS | j | ƒ \ } } } } | d k rc x%| D]. } | j | d d ƒs. t j d | ƒ q. q. Wnì| d k r« xÝ| D]. } | j | d d ƒsv t j d | ƒ qv qv Wn¤| d k ró x•| D]. } | j | d d ƒs¾ t j d | ƒ q¾ q¾ Wn\| d
k r;xM| D]. } | j | d d ƒst j d | ƒ qqWn| d k r†x| D]1 } | j | d
| ƒsNt j d | | ƒ qNqNWnÉ | d k rÑxº | D]1 } | j | d
| ƒs™t j d | | ƒ q™q™Wn~ | d k r| j d d
| ƒsOt j d | ƒ qOnG | d k r?| j d d
| ƒsOt j d | ƒ qOn t d | ƒ ‚ d S)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
ÚincludeÚanchorTzno files found matching %rÚexcludez.no previously-included files found matching %rzglobal-includeFz3no files found matching %r anywhere in distributionzglobal-excludezGno previously-included files matching %r found anywhere in distributionzrecursive-includer z-no files found matching %r under directory %rzrecursive-excludezAno previously-included files matching %r found under directory %rÚgraftNz no directories found matching %rÚprunez4no previously-included directories found matching %rzinvalid action %r)Ú_parse_directiveÚ_include_patternr. ÚwarningÚ_exclude_patternr )r Ú directiveÚactionÚpatternsÚthedirZ
dirpatternÚpatternr r r Úprocess_directive{ sP
zManifest.process_directivec C so | j ƒ } t | ƒ d k rA | d d k rA | j d d ƒ n | d } d } } } | d k rª t | ƒ d k rŠ t d
| ƒ ‚ n d d „ | d d … Dƒ } nµ | d k rt | ƒ d k rÛ t d | ƒ ‚ n t | d ƒ } d d „ | d d … Dƒ } nT | d k rOt | ƒ d k r<t d | ƒ ‚ n t | d ƒ } n t d | ƒ ‚ | | | | f S)zŸ
Validate a directive.
:param directive: The directive to validate.
:return: A tuple of action, patterns, thedir, dir_patterns
r r r? rA úglobal-includeúglobal-excludeúrecursive-includeúrecursive-excluderB rC Né z$%r expects ...c S s g | ] } t | ƒ ‘ q Sr )r )r7 Úwordr r r r8 à s z-Manifest._parse_directive..é z*%r expects ...c S s g | ] } t | ƒ ‘ q Sr )r )r7 rS r r r r8 è s z!%r expects a single zunknown action %r)úincludeúexcluderN rO rP rQ úgraftúprune)rU rV rN rO )rP rQ )rW rX )r0 ÚlenÚinsertr r )r rH ÚwordsrI rJ rK Zdir_patternr r r rD Ç s:
zManifest._parse_directiveTc C sz d } | j | | | | ƒ } | j d k r: | j ƒ n x9 | j D]. } | j | ƒ rD | j j | ƒ d } qD qD W| 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&