File: //opt/alt/python37/lib/python3.7/site-packages/zipp/__pycache__/__init__.cpython-37.pyc
B
XP�e�) � @ s� d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZddlm Z dgZ
dd� Zdd� Ze
jZd d
� ZG dd� d�ZG d
d� deej�ZG dd� de�Zddd�ZG dd� d�ZdS )� N� )�
text_encoding�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 �>/opt/alt/python37/lib/python3.7/site-packages/zipp/__init__.py�_parents s r c c s8 | � tj�} x&| r2| tjkr2| V t�| �\} }qW 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 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
�_difference= s r c s4 e Zd ZdZ� fdd�Zdd� Z� fdd�Z� ZS )�InitializedStatez?
Mix-in to save the initialization state for pickling.
c s || _ || _t� j||� d S )N)�_InitializedState__args�_InitializedState__kwargs�super�__init__)�self�args�kwargs)� __class__r r
r J s zInitializedState.__init__c C s | j | jfS )N)r r )r r r r
�__getstate__O s zInitializedState.__getstate__c s |\}}t � j||� d S )N)r r )r �stater r )r r r
�__setstate__R s zInitializedState.__setstate__)�__name__�
__module__�__qualname__�__doc__r r r �
__classcell__r r )r r
r E s r c sT e Zd ZdZedd� �Z� fdd�Zdd� Zdd � Z� fd
d�Z e
dd
� �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 )N)r
r )�.0�pr r r
� <genexpr>e s z-CompleteDirs._implied_dirs.<locals>.<genexpr>)r �chain�
from_iterable�mapr �_deduper )�names�parentsZas_dirsr r r
�
_implied_dirsb s zCompleteDirs._implied_dirsc s t � �� }|t| �|�� S )N)r �namelist�listr0 )r r. )r r r
r1 h s
zCompleteDirs.namelistc C s t | �� �S )N)r r1 )r r r r
� _name_setl s zCompleteDirs._name_setc C s, | � � }|d }||ko||k}|r(|S |S )zx
If the name represents a directory, return that name
as a directory (with the trailing slash).
�/)r3 )r �namer. �dirnameZ dir_matchr r r
�resolve_diro s zCompleteDirs.resolve_dirc sF yt � �|�S tk
r@ |�d�r2|| �� kr4� tj|d�S X dS )z6
Supplement getinfo for implied dirs.
r4 )�filenameN)r �getinfo�KeyError�endswithr3 �zipfile�ZipInfo)r r5 )r r r
r9 y s zCompleteDirs.getinfoc C s: t |t�r|S t |tj�s"| |�S d|jkr0t} | |_|S )zl
Given a source (filename or zipfile), return an
appropriate CompleteDirs subclass.
�r)�
isinstancer&