a
f:. @ s d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl
mZ ddlm
Z
dgZdd Zd d
ZejZdd ZG d
d dZG dd deejZG dd deZdddZG dd dZdS )z
A Path-like interface for zipfiles.
This codebase is shared between zipfile.Path in the stdlib
and zipp in PyPI. See
https://github.com/python/importlib_metadata/wiki/Development-Methodology
for more detail.
N )
text_encoding)
TranslatorPathc C s t t| ddS )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(''))
[]
r N) itertoolsislice _ancestry)path r
1/usr/lib/python3.9/site-packages/zipp/__init__.py_parents s r c c s2 | tj} | tjr.| V t| \} }qdS )a
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(''))
[]
Multiple separators are treated like a single.
>>> list(_ancestry('//b//d///f//'))
['//b//d///f', '//b//d', '//b']
N)rstrip posixpathsepsplit)r tailr
r
r r . s r c C s t t|j| S )zZ
Return items in minuend not in subtrahend, retaining order
with O(1) lookup.
)r filterfalseset__contains__)ZminuendZ
subtrahendr
r
r _differenceM s r c s4 e Zd ZdZ fddZdd Z fddZ ZS )InitializedStatez?
Mix-in to save the initialization state for pickling.
c s" || _ || _t j|i | d S N)_InitializedState__args_InitializedState__kwargssuper__init__)selfargskwargs __class__r
r r Z s zInitializedState.__init__c C s | j | jfS r )r r r r
r
r __getstate___ s zInitializedState.__getstate__c s |\}}t j|i | d S r )r r )r stater r r r
r __setstate__b s zInitializedState.__setstate__)__name__
__module____qualname____doc__r r" r$
__classcell__r
r
r r r U s r c sl e Zd ZdZedd Z fddZdd Zdd Z fd
dZ e
dd
Ze
ej
ej
dddZ ZS )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/']
c C s. t jtt| }dd |D }tt|| S )Nc s s | ]}|t j V qd S r )r r ).0pr
r
r