관리-도구
편집 파일: context.cpython-311.pyc
� �܋fe% � � � d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl Z d dl Zd dlZd dl mZ ej dk rd dlmZ nd dlZej dd �� � Zej dd d �� � Zd!d�Zd� Z eee� � Zej d� � � Zd� Zej ej fd�� � Zej ddefd�� � Zd� Z G d� d� � Z G d� dej ej � � Z G d� dej � � Z!dS )"� )�annotationsN)�Iterator)� � )�tarfile�dir�str | os.PathLike�return�Iterator[str | os.PathLike]c # � K � t j � � }t j | � � | V � t j |� � dS # t j |� � w xY w)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 �origs �[/opt/cloudlinux/venv/lib64/python3.11/site-packages/pkg_resources/_vendor/jaraco/context.py�pushdr sQ � � � � �9�;�;�D��H�S�M�M�M��� � � � ������������������s �A �A� target_dir�str | os.PathLike | Nonec # � K � |�Gt j � | � � � dd� � � dd� � }t j |� � t j � | � � }t j |d�� � 5 }|� |t �� � ddd� � n# 1 swxY w Y |V � t j |� � dS # t j |� � w xY w)a� Get a tarball, extract it, yield, then clean up. >>> 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) 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�tfs r �tarballr) '