File: //usr/lib/python3/dist-packages/__pycache__/zipp.cpython-39.pyc
a
�^� � @ sj d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZe Z
dd� Zdd� ZG dd� d�Z
dS ) � )�divisionNc 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(''))
[]
� N)� itertools�islice� _ancestry��path� r �&/usr/lib/python3/dist-packages/zipp.py�_parents s r c c s4 | � tj�} | r0| tjkr0| V t�| �\} }qdS )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 @ s� e Zd ZdZdZd,dd�Zedd� �Zedd � �Z ed
d� �Z
dd
� Zdd� Zdd� Z
dd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zd d!� ZeZed"d#� �Zed$d%� �Zed&d'� �Zd(d)� Zejd*k r�eZd+S )-�Pathu�
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 = '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('abcde.zip', 'a.txt')
>>> b
Path('abcde.zip', 'b/')
name property:
>>> b.name
'b'
join with divide operator:
>>> c = b / 'c.txt'
>>> c
Path('abcde.zip', 'b/c.txt')
>>> c.name
'c.txt'
Read text:
>>> c.read_text()
'content of c'
existence:
>>> c.exists()
True
>>> (b / 'missing.txt').exists()
False
Coercion to string:
>>> str(c)
'abcde.zip/b/c.txt'
z>{self.__class__.__name__}({self.root.filename!r}, {self.at!r})� c C s, t |tj�r|nt�| �|��| _|| _d S �N)�
isinstance�zipfileZZipFile�_pathlib_compat�root�at)�selfr r r r r
�__init__} s
��z
Path.__init__c C s* z
| � � W S ty$ t| � Y S 0 dS )zu
For path-like objects, convert to a filename for compatibility
on Python 3.6.1 and earlier.
N)�
__fspath__�AttributeError�strr r r r
r � s
zPath._pathlib_compatc C s t �| jj| j�S r )� functools�partialr �openr �r r r r
r � s z Path.openc C s t �| j�d��S �N�/)r
�basenamer r r! r r r
�name� s z Path.namec O sH | � � �,}tj|g|�R i |���� W d � S 1 s:0 Y d S r )r �io�
TextIOWrapper�read)r �args�kwargs�strmr r r
� read_text� s
zPath.read_textc C s4 | � � �}|�� W d � S 1 s&0 Y d S r )r r( )r r+ r r r
�
read_bytes� s
zPath.read_bytesc C s t �|j�d��| j�d�kS r"