%PDF- %PDF-
Direktori : /lib/python3/dist-packages/__pycache__/ |
Current File : //lib/python3/dist-packages/__pycache__/zipp.cpython-312.pyc |
� LJ�f � � � d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl Z e Zd� Zd� Z G d� d� Z G d� d� Zy) � )�divisionNc �B � t j 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��paths �&/usr/lib/python3/dist-packages/zipp.py�_parentsr s � � ���I�d�O�Q��5�5� c # �� K � | j t j � } | rH| t j k7 r4| �� t j | � \ } }| r| t j k7 r�2yyyy�w)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 �tails r r r % sV � �� � �;�;�y�}�}�%�D� �4�9�=�=�(�� ��_�_�T�*� ��d� �4�9�=�=�(�$�(�$�s �A&A-�)A-c �2 � � e Zd ZdZ� fd�Zed� � Z� xZS )�SanitizedNamesz7 ZipFile mix-in to ensure names are sanitized. c �Z �� t t | j t �| � � � � S �N)�list�map� _sanitize�super�namelist)�self� __class__s �r r zSanitizedNames.namelist? s! �� ��C������(8�(:�;�<�<r c � � d� }t j dd| t j �� }|j dd� }|j d� }dj t ||� � }|st d� �|d| j d� z z S )a] Ensure a relative path with posix separators and no dot names. Modeled after https://github.com/python/cpython/blob/bcc1be39cb1d04ad9fc0bd1b9193d3972835a57c/Lib/zipfile/__init__.py#L1799-L1813 but provides consistent cross-platform behavior. >>> san = SanitizedNames._sanitize >>> san('/foo/bar') 'foo/bar' >>> san('//foo.txt') 'foo.txt' >>> san('foo/.././bar.txt') 'foo/bar.txt' >>> san('foo../.bar.txt') 'foo../.bar.txt' >>> san('\\foo\\bar.txt') 'foo/bar.txt' >>> san('D:\\foo.txt') 'D/foo.txt' >>> san('\\\\server\\share\\file.txt') 'server/share/file.txt' >>> san('\\\\?\\GLOBALROOT\\Volume3') '?/GLOBALROOT/Volume3' >>> san('\\\\.\\PhysicalDrive1\\root') 'PhysicalDrive1/root' Retain any trailing slash. >>> san('abc/') 'abc/' Raises a ValueError if the result is empty. >>> san('../..') Traceback (most recent call last): ... ValueError: Empty filename c � � | xr | dvS )N> �..�.� )�parts r �allowedz)SanitizedNames._sanitize.<locals>.allowedf s � ��3�D��3�3r z ^([A-Z]):z\1)�flags�\�/zEmpty filename) �re�sub� IGNORECASE�replacer �join�filter� ValueError�endswith)�namer% �bare�clean�parts�joineds r r zSanitizedNames._sanitizeB s} � �H 4� �v�v�k�5�$�b�m�m�D�����T�3�'�����C� �����&��%�0�1����-�.�.���d�m�m�C�0�0�0�0r )�__name__� __module__�__qualname__�__doc__r �staticmethodr � __classcell__)r s @r r r : s! �� ��=� �.1� �.1r r c �� � e Zd ZdZdZdd�Zed� � Zed� � Z ed� � Z d� Zd� Zd � Z d � Zd� Zd� Zd � Zd� Zd� Zd� Zd� ZeZed� � Zed� � Zed� � Zd� Zej: dk reZyy)�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 � � t |t j � r|n#t j | j |� � | _ || _ y r )� isinstance�zipfile�ZipFile�_pathlib_compat�root�at)r rC rD s r �__init__z Path.__init__� s>