zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
U
H=®dÛ9ã@s¤dZddlZddlZddlZddlZddlZddlmZddlm    Z    ddl
m Z dgZ e  e¡Ze dej¡Ze d    ejejB¡Zejdd
…ZGd d„deƒZdS) 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@szeZdZdZddd„Zdd„Zdd„Zd    d
„Zdd d „Zdd„Z    dd„Z
dd„Z ddd„Z d dd„Z d!dd„Zdd„ZdS)"rz~A list of files built by on exploring the filesystem and filtered by
    applying various patterns to what we find there.
    NcCs>tj tj |pt ¡¡¡|_|jtj|_d|_t    ƒ|_
dS)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úSD:\z\workplace\VsCode\pyvenv\venv\Lib\site-packages\pip/_vendor/distlib/manifest.pyÚ__init__*szManifest.__init__cCs¨ddlm}m}m}g|_}|j}|g}|j}|j}|r¤|ƒ}t     |¡}    |    D]R}
tj
  ||
¡} t | ¡} | j } || ƒrˆ| t | ƒ¡qN|| ƒrN|| ƒsN|| ƒqNq6dS)zmFind all files under the base and set ``allfiles`` to the absolute
        pathnames of files found.
        r)ÚS_ISREGÚS_ISDIRÚS_ISLNKN)ÚstatrrrrrÚpopÚappendr    Úlistdirr
ÚjoinÚst_moder)rrrrrÚrootÚstackrÚpushÚnamesÚnameÚfullnamerÚmoderrrÚfindall9s"
 
 
zManifest.findallcCs4| |j¡stj |j|¡}|j tj |¡¡dS)zz
        Add a file to the manifest.
 
        :param item: The pathname to add. This can be relative to the base.
        N)    Ú
startswithrr    r
rrrÚaddr )rÚitemrrrr*Ts z Manifest.addcCs|D]}| |¡qdS)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+rrrÚadd_many^szManifest.add_manyFcsb‡‡fdd„‰tˆjƒ}|rFtƒ}|D]}ˆ|tj |¡ƒq&||O}dd„tdd„|DƒƒDƒS)z8
        Return sorted files in directory order
        csJ| |¡t d|¡|ˆjkrFtj |¡\}}|dks<t‚ˆ||ƒdS)Nzadd_dir added %s)Úú/)r*ÚloggerÚdebugrr    r
ÚsplitÚAssertionError)ÚdirsÚdÚparentÚ_©Úadd_dirrrrr9ls 
 
 z Manifest.sorted.<locals>.add_dircSsg|]}tjj|Ž‘qSr)r    r
r)Ú.0Z
path_tuplerrrÚ
<listcomp>zsz#Manifest.sorted.<locals>.<listcomp>css|]}tj |¡VqdS)N)r    r
r2)r:r
rrrÚ    <genexpr>{sz"Manifest.sorted.<locals>.<genexpr>)rrr    r
ÚdirnameÚsorted)rZwantdirsÚresultr4Úfrr8rr>gs
ÿzManifest.sortedcCstƒ|_g|_dS)zClear all collected files.N)rrr)rrrrÚclear}szManifest.clearcCsj| |¡\}}}}|dkrB|D]}|j|ddst d|¡qn$|dkrf|D]}|j|dd}qNn|dkr”|D]}|j|ddsrt d|¡qrnÒ|d    kr¶|D]}|j|dd}q n°|d
kræ|D] }|j||d sÂt d ||¡qÂn€|d kr
|D]}|j||d }qôn\|dkr2|jd|d sft d|¡n4|dkrZ|jd|d sft d|¡n td|ƒ‚dS)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)Úanchorzno files found matching %rÚexcludeúglobal-includeFz3no files found matching %r anywhere in distributionúglobal-excludeúrecursive-include)rz-no files found matching %r under directory %rúrecursive-excludeÚgraftNz no directories found matching %rÚprunez4no previously-included directories found matching %rzinvalid action %r)Ú_parse_directiveÚ_include_patternr0ÚwarningÚ_exclude_patternr)rÚ    directiveÚactionÚpatternsÚthedirZ
dirpatternÚpatternÚfoundrrrÚprocess_directive‚sPÿÿ
 
ÿ
ÿÿzManifest.process_directivecCs| ¡}t|ƒdkr,|ddkr,| dd¡|d}d}}}|dkrxt|ƒdkr`td|ƒ‚d    d
„|dd…Dƒ}n~|d kr¼t|ƒd kr˜td |ƒ‚t|dƒ}dd
„|dd…Dƒ}n:|dkrêt|ƒdkrÜtd|ƒ‚t|dƒ}n td|ƒ‚||||fS)zŸ
        Validate a directive.
        :param directive: The directive to validate.
        :return: A tuple of action, patterns, thedir, dir_patterns
        rr)rBrDrErFrGrHrIrJrBN)rBrDrErFrz$%r expects <pattern1> <pattern2> ...cSsg|] }t|ƒ‘qSrr©r:Úwordrrrr;êsz-Manifest._parse_directive.<locals>.<listcomp>)rGrHéz*%r expects <dir> <pattern1> <pattern2> ...cSsg|] }t|ƒ‘qSrrrVrrrr;òs)rIrJz!%r expects a single <dir_pattern>zunknown action %r)r2ÚlenÚinsertrr)rrOÚwordsrPrQrRZ dir_patternrrrrKÑs4   ÿ ÿ  ÿ zManifest._parse_directiveTcCsPd}| ||||¡}|jdkr&| ¡|jD]}| |¡r,|j |¡d}q,|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_patternrr(Úsearchrr*)rrSrCrÚis_regexrTÚ
pattern_rer%rrrrLs
 
 
 zManifest._include_patterncCsBd}| ||||¡}t|jƒD]}| |¡r|j |¡d}q|S)atRemove 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)r\Úlistrr]Úremove)rrSrCrr^rTr_r@rrrrN)s 
 zManifest._exclude_patternc Cs¨|rt|tƒrt |¡S|Stdkr:| d¡ d¡\}}}|rj| |¡}tdkrn| |¡rd| |¡snt    ‚nd}t 
t j   |jd¡¡}    |dk    rftdkrº| d¡}
| |¡dt|
ƒ …} n>| |¡} |  |¡rØ|  |¡sÜt    ‚| t|ƒt| ƒt|ƒ…} t j} t jdkrd} tdkr4d|    |   | d|f¡}n0|t|ƒt|ƒt|ƒ…}d    ||    | | ||f}n8|ržtdkr„d|    |}nd
||    |t|ƒd…f}t |¡S) aTranslate 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).
        )rXrr7r.Nú\z\\ú^z.*z%s%s%s%s.*%s%sz%s%s%s)Ú
isinstanceÚstrÚreÚcompileÚ_PYTHON_VERSIONÚ _glob_to_reÚ    partitionr)Úendswithr3Úescaper    r
rrrYr) rrSrCrr^Ústartr7Úendr_rZ empty_patternZ    prefix_rerrrrr\=sH    
 
 
 
 
 
 
 ÿ
 
ÿ
zManifest._translate_patterncCs8t |¡}tj}tjdkrd}d|}t 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).
        rbz\\\\z\1[^%s]z((?<!\\)(\\\\)*)\.)ÚfnmatchÚ    translater    rrfÚsub)rrSr_rÚescapedrrrrits
 
zManifest._glob_to_re)N)F)TNF)TNF)TNF)Ú__name__Ú
__module__Ú __qualname__Ú__doc__rr(r*r-r>rArUrKrLrNr\rirrrrr%s&
 
    
O/ÿ
)ÿ
ÿ
7)rvroÚloggingr    rfÚsysr.rÚcompatrÚutilrÚ__all__Ú    getLoggerrsr0rgÚMZ_COLLAPSE_PATTERNÚSZ_COMMENTED_LINEÚ version_inforhÚobjectrrrrrÚ<module>s