�
,�Re, � �N � d dl Z d dlZd dlZd dlZd dlZd dlZd dlZej d� � � Zej ddefd�� � Z d� Z
ej ej fd�� � Zej ddefd�� � Z
ej d� � � Z G d � d
� � Z G d� dej ej � � ZdS )
� Nc # � K � t j � � }t j | � � | V � t j |� � d S # t j |� � w xY w�N)�os�getcwd�chdir)�dir�origs ��/builddir/build/BUILDROOT/alt-python311-setuptools-65.6.3-2.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/setuptools/_vendor/jaraco/context.py�pushdr
sO � � � �
�9�;�;�D��H�S�M�M�M��� � � �
������������������s �A �Ac
# � K � |�Gt j � | � � � dd� � � dd� � }|� t j t j d�� � } | dj d
i t � � ��� � d}d }d
�
||f� � } | |j d
dt | � � it � � ��� � ||� � 5 |V � ddd� � n# 1 swxY w Y | dj d
i t � � ��� � dS # | dj d
i t � � ��� � w xY w)z�
Get a tarball, extract it, change to that directory, yield, then
clean up.
`runner` is the function to invoke commands.
`pushd` is a context manager for changing the directory.
Nz.tar.gz� z.tgzT)�shellzmkdir {target_dir}zwget {url} -O -z7tar x{compression} --strip-components=1 -C {target_dir}z | �compressionzrm -Rf {target_dir}� )r �path�basename�replace� functools�partial�
subprocess�
check_call�format�vars�join�infer_compression)�url�
target_dir�runnerr �getter�extract�cmds r
�tarball_contextr" s� � � � � ���W�%�%�c�*�*�2�2�9�b�A�A�I�I�&�RT�U�U�
�
�~��"�:�#8��E�E�E��
�F�&��&�0�0����0�0�1�1�1�7�"��K���j�j�&�'�*�+�+����z�s�z�G�G�&7��&<�&<�G����G�G�H�H�H�
�U�:�
�
� � ����� � � � � � � � � � � ���� � � � � ��+�$�+�5�5�d�f�f�5�5�6�6�6�6�6����+�$�+�5�5�d�f�f�5�5�6�6�6�6���s1 �AD( �(C9�-D( �9C=�=D( � C=�D( �($Ec �f � | dd� }t ddd�� � }|� |d� � S )zF
Given a URL or filename, infer the compression code for tar.
�����N�z�j�J)�gz�bz�xz)�dict�get)r �compression_indicator�mappings r
r r 0 s; � �
����H���c�c�c�*�*�*�G��;�;�,�c�2�2�2� c # �p K � t j � � } |V � | |� � dS # | |� � w xY w)zk
Create a temporary directory context. Pass a custom remover
to override the removal behavior.
N)�tempfile�mkdtemp)�remover�temp_dirs r
r4 r4 ; sP � � � � ��!�!�H������������������������s �( �
5Tc # � K � d| v rdnd} |� � 5 }|d| |g}|r|� d|g� � t t j j d� � }|r|nd}t j ||�� � |V � ddd� � dS # 1 swxY w Y dS )z�
Check out the repo indicated by url.
If dest_ctx is supplied, it should be a context manager
to yield the target directory for the check out.
�git�hg�clonez--branch�wN)�stdout)�extend�openr r �devnullr r ) r �branch�quiet�dest_ctx�exe�repo_dirr! r= r: s r
�repo_contextrC H s� � � � � �C�<�<�%�%�T�C� ���� �x��G�S�(�+��� -��J�J�
�F�+�,�,�,��r�w���,�,��!�+���t����c�&�1�1�1�1������ � � � � � � � � � � ���� � � � � � s �AB�B�Bc # � K � d V � d S r r r r/ r
�nullrE [ s � � � � �E�E�E�E�Er/ c � � e Zd ZdZdZeffd�Zd� Zed� � � Z ed� � � Z
ed� � � Zd� Zd � Z
ed
�d�Zd� Zd
S )�
ExceptionTrapaG
A context manager that will catch certain exceptions and provide an
indication they occurred.
>>> with ExceptionTrap() as trap:
... raise Exception()
>>> bool(trap)
True
>>> with ExceptionTrap() as trap:
... pass
>>> bool(trap)
False
>>> with ExceptionTrap(ValueError) as trap:
... raise ValueError("1 + 1 is not 3")
>>> bool(trap)
True
>>> with ExceptionTrap(ValueError) as trap:
... raise Exception()
Traceback (most recent call last):
...
Exception
>>> bool(trap)
False
)NNNc � � || _ d S r )�
exceptions)�selfrI s r
�__init__zExceptionTrap.__init__� s
� �$����r/ c � � | S r r �rJ s r
� __enter__zExceptionTrap.__enter__� s � ��r/ c � � | j d S �Nr ��exc_inforM s r
�typezExceptionTrap.type� � � ��}�Q��r/ c � � | j d S )N� rQ rM s r
�valuezExceptionTrap.value� rT r/ c � � | j d S )N� rQ rM s r
�tbzExceptionTrap.tb� rT r/ c �V � |d }|ot || j � � }|r|| _ |S rP )�
issubclassrI rR )rJ rR rS �matchess r
�__exit__zExceptionTrap.__exit__� s5 � ���{���<�:�d�D�O�<�<��� %�$�D�M��r/ c �* � t | j � � S r )�boolrS rM s r
�__bool__zExceptionTrap.__bool__� s � ��D�I���r/ ��_testc �N � ��� t j �� � ��� fd�� � }|S )a�
Wrap func and replace the result with the truth
value of the trap (True if an exception occurred).
First, give the decorator an alias to support Python 3.8
Syntax.
>>> raises = ExceptionTrap(ValueError).raises
Now decorate a function that always fails.
>>> @raises
... def fail():
... raise ValueError('failed')
>>> fail()
True
c � �� t �j � � 5 } �| i |�� d d d � � n# 1 swxY w Y �|� � S r )rG rI )�args�kwargs�traprc �funcrJ s ���r
�wrapperz%ExceptionTrap.raises.