Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/jaraco/context/__pycache__/__init__.cpython-39.pyc
Ðазад
a j�h�$ � @ st d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl Z d dl Z d dlZd dlZd dl Zd dlmZ ejdk r�d dlmZ nd dlZejddd�d d ��Zejd(ddd�d d��Zddd�dd�Zdd� Zeee�Zdd� Zdd� Zejejfdd��Zejee� d�Zejddefddd�d d!��Z G d"d#� d#�Z!G d$d%� d%ej"ej#�Z"G d&d'� d'ej#�Z$dS ))� )�annotationsN)�Iterator)� � )�tarfilezstr | os.PathLikezIterator[str | os.PathLike])�dir�returnc c s8 t �� }t �| � z| V W t �|� nt �|� 0 dS )z� >>> tmp_path = getfixture('tmp_path') >>> with pushd(tmp_path): ... assert os.getcwd() == os.fspath(tmp_path) >>> assert os.getcwd() != os.fspath(tmp_path) N)�os�getcwd�chdir)r �orig� r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/jaraco/context/__init__.py�pushd s r zstr | os.PathLike | None)� target_dirr c c s� |du r$t j�| ��dd��dd�}t �|� z\tj�| �}tj |dd��}|j |td� W d � n1 sn0 Y |V W t� |� nt� |� 0 dS )au Get a URL to a tarball, download, extract, yield, then clean up. Assumes everything in the tarball is prefixed with a common directory. That common path is stripped and the contents are extracted to ``target_dir``, similar to passing ``-C {target} --strip-components 1`` to the ``tar`` command. Uses the streaming protocol to extract the contents from a stream in a single pass without loading the whole file into memory. >>> import urllib.request >>> url = getfixture('tarfile_served') >>> target = getfixture('tmp_path') / 'out' >>> tb = tarball(url, target_dir=target) >>> import pathlib >>> with tb as extracted: ... contents = pathlib.Path(extracted, 'contents.txt').read_text(encoding='utf-8') >>> assert not os.path.exists(extracted) If the target is not specified, contents are extracted to a directory relative to the current working directory named after the name of the file as extracted from the URL. >>> target = getfixture('tmp_path') >>> with pushd(target), tarball(url): ... target.joinpath('served').is_dir() True Nz.tar.gz� z.tgzzr|*)�fileobj�mode)�path�filter)r r �basename�replace�mkdir�urllib�request�urlopenr �open� extractall�strip_first_component�shutil�rmtree)�urlr �req�tfr r r �tarball) s " ,r$ ztarfile.TarInfo)�memberr c C s | j �dd�\}| _ | S )N�/� )�name�split)r% r �_r r r r W s r c G s dd� }t �|t| ��S )a� Compose any number of dependent context managers into a single one. The last, innermost context manager may take arbitrary arguments, but each successive context manager should accept the result from the previous as a single parameter. Like :func:`jaraco.functools.compose`, behavior works from right to left, so the context manager should be indicated from outermost to innermost. Example, to create a context manager to change to a temporary directory: >>> temp_dir_as_cwd = _compose(pushd, temp_dir) >>> with temp_dir_as_cwd() as dir: ... assert os.path.samefile(os.getcwd(), dir) c s � �fdd�}t �|�S )Nc ? s` � | i |���>}�|��}|V W d � n1 s40 Y W d � n1 sR0 Y d S �Nr )�args�kwargsZsaved�res��inner�outerr r �composedt s z/_compose.<locals>.compose_two.<locals>.composed)� contextlib�contextmanager)r0 r1 r2 r r/ r �compose_twos s z_compose.<locals>.compose_two)� functools�reduce�reversed)Zcmgrsr5 r r r �_compose_ s r9 c C sT |\}}}| t jt jt jfv rN|jtjkrNt �|tjtj B tj B � | |� n� dS )z> Add support for removing read-only files on Windows. N)r �rmdir�remove�unlink�errno�EACCES�chmod�stat�S_IRWXU�S_IRWXG�S_IRWXO)�funcr �exc_infor* �excr r r �remove_readonly� s rG c C s"