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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
U
ß=®d´)ã@s¾ddlZddlZddlZddlZddlZddlZddlZddlZddlm    Z    dgZ
dd„Z dd„Z e jZd    d
„ZGd d „d ƒZGd d„deejƒZGdd„deƒZddd„ZGdd„dƒZdS)éNé©Ú text_encodingÚPathcCst t|ƒdd¡S)a2
    Given a path with elements separated by
    posixpath.sep, generate all parents of that path.
 
    >>> list(_parents('b/d'))
    ['b']
    >>> list(_parents('/b/d/'))
    ['/b']
    >>> list(_parents('b/d/f/'))
    ['b/d', 'b']
    >>> list(_parents('b'))
    []
    >>> list(_parents(''))
    []
    rN)Ú    itertoolsÚisliceÚ    _ancestry)Úpath©r
úDd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\zipp/__init__.pyÚ_parentssr ccs4| tj¡}|r0|tjkr0|Vt |¡\}}q dS)aR
    Given a path with elements separated by
    posixpath.sep, generate all elements of that path
 
    >>> list(_ancestry('b/d'))
    ['b/d', 'b']
    >>> list(_ancestry('/b/d/'))
    ['/b/d', '/b']
    >>> list(_ancestry('b/d/f/'))
    ['b/d/f', 'b/d', 'b']
    >>> list(_ancestry('b'))
    ['b']
    >>> list(_ancestry(''))
    []
    N)ÚrstripÚ    posixpathÚsepÚsplit)r    Útailr
r
r r#s rcCst t|ƒj|¡S)zZ
    Return items in minuend not in subtrahend, retaining order
    with O(1) lookup.
    )rÚ filterfalseÚsetÚ __contains__)ÚminuendÚ
subtrahendr
r
r Ú _difference=srcs4eZdZdZ‡fdd„Zdd„Z‡fdd„Z‡ZS)ÚInitializedStatez?
    Mix-in to save the initialization state for pickling.
    cs||_||_tƒj||ŽdS©N)Ú_InitializedState__argsÚ_InitializedState__kwargsÚsuperÚ__init__)ÚselfÚargsÚkwargs©Ú    __class__r
r rJszInitializedState.__init__cCs |j|jfSr)rr©rr
r
r Ú __getstate__OszInitializedState.__getstate__cs|\}}tƒj||ŽdSr)rr)rÚstaterr r!r
r Ú __setstate__RszInitializedState.__setstate__)Ú__name__Ú
__module__Ú __qualname__Ú__doc__rr$r&Ú __classcell__r
r
r!r rEs rcsTeZdZdZedd„ƒZ‡fdd„Zdd„Zdd    „Z‡fd
d „Z    e
d d „ƒZ ‡Z S)Ú CompleteDirsa8
    A ZipFile subclass that ensures that implied directories
    are always included in the namelist.
 
    >>> list(CompleteDirs._implied_dirs(['foo/bar.txt', 'foo/bar/baz.txt']))
    ['foo/', 'foo/bar/']
    >>> list(CompleteDirs._implied_dirs(['foo/bar.txt', 'foo/bar/baz.txt', 'foo/bar/']))
    ['foo/']
    cCs.tj tt|ƒ¡}dd„|Dƒ}tt||ƒƒS)Ncss|]}|tjVqdSr)rr)Ú.0Úpr
r
r Ú    <genexpr>esz-CompleteDirs._implied_dirs.<locals>.<genexpr>)rÚchainÚ from_iterableÚmapr Ú_deduper)ÚnamesÚparentsÚas_dirsr
r
r Ú _implied_dirsbszCompleteDirs._implied_dirscstƒ ¡}|t| |¡ƒSr)rÚnamelistÚlistr7)rr4r!r
r r8hs
zCompleteDirs.namelistcCs t| ¡ƒSr)rr8r#r
r
r Ú    _name_setlszCompleteDirs._name_setcCs,| ¡}|d}||ko||k}|r(|S|S)zx
        If the name represents a directory, return that name
        as a directory (with the trailing slash).
        ú/)r:)rÚnamer4ÚdirnameÚ    dir_matchr
r
r Ú resolve_diroszCompleteDirs.resolve_dircsLztƒ |¡WStk
rF| d¡r4|| ¡kr6‚tj|dYSXdS)z6
        Supplement getinfo for implied dirs.
        r;)ÚfilenameN)rÚgetinfoÚKeyErrorÚendswithr:ÚzipfileÚZipInfo)rr<r!r
r rAys zCompleteDirs.getinfocCs:t|tƒr|St|tjƒs"||ƒSd|jkr0t}||_|S)zl
        Given a source (filename or zipfile), return an
        appropriate CompleteDirs subclass.
        Úr)Ú
isinstancer,rDÚZipFileÚmoder")ÚclsÚsourcer
r
r Úmake„s
 
zCompleteDirs.make) r'r(r)r*Ú staticmethodr7r8r:r?rAÚ classmethodrLr+r
r
r!r r,Ws
 
 
r,cs,eZdZdZ‡fdd„Z‡fdd„Z‡ZS)Ú
FastLookupzV
    ZipFile subclass to ensure implicit
    dirs exist and are resolved rapidly.
    c
s6t t¡|jW5QR£SQRXtƒ ¡|_|jSr)Ú
contextlibÚsuppressÚAttributeErrorÚ_FastLookup__namesrr8r#r!r
r r8žs  zFastLookup.namelistc
s6t t¡|jW5QR£SQRXtƒ ¡|_|jSr)rPrQrRÚ_FastLookup__lookuprr:r#r!r
r r:¤s  zFastLookup._name_set)r'r(r)r*r8r:r+r
r
r!r rO˜s rOcOst|dƒ||fS)Nér)Úencodingrr r
r
r Ú_extract_text_encoding«srWc@seZdZdZdZd=dd„Zdd„Zdd    „Zd>d d œd d„Ze    dd„ƒZ
e    dd„ƒZ e    dd„ƒZ e    dd„ƒZ e    dd„ƒZdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1d2„Zd3d4„Zd5d6„Zd7d8„Zd9d:„ZeZ e    d;d<„ƒZ!d S)?ruD
    A pathlib-compatible interface for zip files.
 
    Consider a zip file with this structure::
 
        .
        â”œâ”€â”€ a.txt
        â””── b
            â”œâ”€â”€ c.txt
            â””── d
                â””── e.txt
 
    >>> data = io.BytesIO()
    >>> zf = zipfile.ZipFile(data, 'w')
    >>> zf.writestr('a.txt', 'content of a')
    >>> zf.writestr('b/c.txt', 'content of c')
    >>> zf.writestr('b/d/e.txt', 'content of e')
    >>> zf.filename = 'mem/abcde.zip'
 
    Path accepts the zipfile object itself or a filename
 
    >>> root = Path(zf)
 
    From there, several path operations are available.
 
    Directory iteration (including the zip file itself):
 
    >>> a, b = root.iterdir()
    >>> a
    Path('mem/abcde.zip', 'a.txt')
    >>> b
    Path('mem/abcde.zip', 'b/')
 
    name property:
 
    >>> b.name
    'b'
 
    join with divide operator:
 
    >>> c = b / 'c.txt'
    >>> c
    Path('mem/abcde.zip', 'b/c.txt')
    >>> c.name
    'c.txt'
 
    Read text:
 
    >>> c.read_text(encoding='utf-8')
    'content of c'
 
    existence:
 
    >>> c.exists()
    True
    >>> (b / 'missing.txt').exists()
    False
 
    Coercion to string:
 
    >>> import os
    >>> str(c).replace(os.sep, posixpath.sep)
    'mem/abcde.zip/b/c.txt'
 
    At the root, ``name``, ``filename``, and ``parent``
    resolve to the zipfile. Note these attributes are not
    valid and will raise a ``ValueError`` if the zipfile
    has no filename.
 
    >>> root.name
    'abcde.zip'
    >>> str(root.filename).replace(os.sep, posixpath.sep)
    'mem/abcde.zip'
    >>> str(root.parent)
    'mem'
    z>{self.__class__.__name__}({self.root.filename!r}, {self.at!r})ÚcCst |¡|_||_dS)aX
        Construct a Path from a ZipFile or filename.
 
        Note: When the source is an existing ZipFile object,
        its type (__class__) will be mutated to a
        specialized type. If the caller wishes to retain the
        original type, the caller should either create a
        separate ZipFile object or pass a filename.
        N)rOrLÚrootÚat)rrYrZr
r
r rs
z Path.__init__cCs(|j|jk    rtS|j|jf|j|jfkS)zU
        >>> Path(zipfile.ZipFile(io.BytesIO(), 'w')) == 'foo'
        False
        )r"ÚNotImplementedrYrZ)rÚotherr
r
r Ú__eq__ s z Path.__eq__cCst|j|jfƒSr)ÚhashrYrZr#r
r
r Ú__hash__sz Path.__hash__rFN©ÚpwdcOs„| ¡rt|ƒ‚|d}| ¡s0|dkr0t|ƒ‚|jj|j||d}d|kr`|sT|r\tdƒ‚|St||Ž\}}}t    j
||f|ž|ŽS)zª
        Open this entry as text or binary following the semantics
        of ``pathlib.Path.open()`` by passing arguments through
        to io.TextIOWrapper().
        rrFr`Úbz*encoding args invalid for binary operation) Úis_dirÚIsADirectoryErrorÚexistsÚFileNotFoundErrorrYÚopenrZÚ
ValueErrorrWÚioÚ TextIOWrapper)rrIrarr Zzip_modeÚstreamrVr
r
r rgsz    Path.opencCst |j¡jp|jjSr)ÚpathlibrrZr<r@r#r
r
r r<-sz    Path.namecCst |j¡jp|jjSr)rlrrZÚsuffixr@r#r
r
r rm1sz Path.suffixcCst |j¡jp|jjSr)rlrrZÚsuffixesr@r#r
r
r rn5sz Path.suffixescCst |j¡jp|jjSr)rlrrZÚstemr@r#r
r
r ro9sz    Path.stemcCst |jj¡ |j¡Sr)rlrrYr@ÚjoinpathrZr#r
r
r r@=sz Path.filenamec
OsDt||Ž\}}}|jd|f|ž|Ž}| ¡W5QR£SQRXdS)NrF)rWrgÚread)rrr rVÚstrmr
r
r Ú    read_textAszPath.read_textc
Cs*| d¡}| ¡W5QR£SQRXdS)NÚrb)rgrq)rrrr
r
r Ú
read_bytesFs zPath.read_bytescCst |j d¡¡|j d¡kS©Nr;)rr=rZr )rr    r
r
r Ú    _is_childJszPath._is_childcCs| |j|¡Sr)r"rY)rrZr
r
r Ú_nextMsz
Path._nextcCs|j p|j d¡Srv)rZrCr#r
r
r rcPsz Path.is_dircCs| ¡o| ¡ Sr)rercr#r
r
r Úis_fileSsz Path.is_filecCs|j|j ¡kSr)rZrYr:r#r
r
r reVsz Path.existscCs.| ¡stdƒ‚t|j|j ¡ƒ}t|j|ƒS)NzCan't listdir a file)rcrhr2rxrYr8Úfilterrw)rÚsubsr
r
r ÚiterdirYsz Path.iterdircCst |j¡ |¡Sr)rlrrZÚmatch)rÚ path_patternr
r
r r}_sz
Path.matchcCsdS)z]
        Return whether this path is a symlink. Always false (python/cpython#82102).
        Fr
r#r
r
r Ú
is_symlinkbszPath.is_symlinkccs.| ¡D] }|V| ¡r| ¡EdHqdSr)r|rcÚ _descendants)rÚchildr
r
r r€hs zPath._descendantscs<|std|›ƒ‚t t |¡¡j‰‡‡fdd„ˆ ¡DƒS)NzUnacceptable pattern: c3s$|]}ˆt| ˆ¡ƒƒr|VqdSr)ÚstrÚ relative_to)r-r©Úmatchesrr
r r/ssþzPath.glob.<locals>.<genexpr>)rhÚreÚcompileÚfnmatchÚ    translateÚ    fullmatchr€©rÚpatternr
r„r Úglobns  þz    Path.globcCs| d|›¡S)Nz**/)rr‹r
r
r Úrglobysz
Path.rglobcGst t|ƒt|j|Žƒ¡Sr)rÚrelpathr‚rp)rr\Úextrar
r
r rƒ|szPath.relative_tocCst |jj|j¡Sr)rÚjoinrYr@rZr#r
r
r Ú__str__sz Path.__str__cCs|jj|dS)Nr#)Ú _Path__reprÚformatr#r
r
r Ú__repr__‚sz Path.__repr__cGs$tj|jf|žŽ}| |j |¡¡Sr)rr‘rZrxrYr?)rr\Únextr
r
r rp…sz Path.joinpathcCs6|js|jjSt |j d¡¡}|r,|d7}| |¡Srv)rZr@Úparentrr=r rx)rÚ    parent_atr
r
r r—‹s z Path.parent)rX)rF)"r'r(r)r*r“rr]r_rgÚpropertyr<rmrnror@rsrurwrxrcryrer|r}rr€rrŽrƒr’r•rpÚ __truediv__r—r
r
r
r r°sHM
    
 
 
 
 
 )N)rirrDrrPrlr†rˆZ py310compatrÚ__all__r rÚdictÚfromkeysr3rrrHr,rOrWrr
r
r
r Ú<module>s$ A