File: //opt/saltstack/salt/lib/python3.10/site-packages/zipp/__pycache__/__init__.cpython-310.pyc
o
;j�- � @ s� d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl m
Z
mZ ddlm
Z
ddlmZ dgZdd � Zd
d� ZejZ dd
� ZG dd� d�ZG dd� deej�ZG dd� de�Zddd�ZG dd� d�ZdS )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� )�none_as�save_method_args��
text_encoding)�
Translator�Pathc C s t �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(''))
[]
r N)� itertools�islice� _ancestry)�path� r
�A/opt/saltstack/salt/lib/python3.10/site-packages/zipp/__init__.py�_parents s r c c sB � | � tj�} | � tj�r| V t�| �\} }| � tj�s
dS dS )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� posixpath�sep�split)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 �filterfalse�set�__contains__)ZminuendZ
subtrahendr
r
r �_differenceL s r c s8 e Zd ZdZe� fdd��Zdd� Z� fdd�Z� ZS )�InitializedStatez?
Mix-in to save the initialization state for pickling.
c s t � j|i |�� d S �N��super�__init__)�self�args�kwargs�� __class__r
r r Y � zInitializedState.__init__c C s | j j| j jfS r )Z_saved___init__r r �r r
r
r �__getstate__] � zInitializedState.__getstate__c s |\}}t � j|i |�� d S r r )r �stater r r! r
r �__setstate__` s zInitializedState.__setstate__) �__name__�
__module__�__qualname__�__doc__r r r% r( �
__classcell__r
r
r! r r T s r c sn e Zd ZdZedd� �Z� fdd�Zdd� Zdd � Z� fd
d�Z e
dd
� �Ze
dej
dej
fdd��Z� 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 j�tt| ��}dd� |D �}tt|| ��S )Nc s s � | ]}|t j V qd S r )r r )�.0�pr
r
r � <genexpr>s s � z-CompleteDirs._implied_dirs.<locals>.<genexpr>)r �chain�
from_iterable�mapr �_deduper )�names�parentsZas_dirsr
r
r �
_implied_dirsp s zCompleteDirs._implied_dirsc s t � �� }|t| �|�� S r )r �namelist�listr8 )r r6 r! r
r r9 v s
zCompleteDirs.namelistc C s t | �� �S r )r r9 r$ r
r
r � _name_setz s zCompleteDirs._name_setc C s, | � � }|d }||vo||v }|r|S |S )zx
If the name represents a directory, return that name
as a directory (with the trailing slash).
�/)r; )r �namer6 �dirnameZ dir_matchr
r
r �resolve_dir} s zCompleteDirs.resolve_dirc sF zt � �|�W S ty" |�d�r|| �� vr� tj|d� Y S w )z6
Supplement getinfo for implied dirs.
r<