HEX
Server: Apache
System: Linux infong-uk86 4.4.400-icpu-106 #2 SMP Mon Sep 15 08:23:40 UTC 2025 x86_64
User: u44115835 (4976590)
PHP: 8.4.17
Disabled: NONE
Upload Files
File: //kunden/lib/python3/dist-packages/breezy/__pycache__/cleanup.cpython-39.pyc
a

�*�^�"�@sddZddlmZddlmZddlZzddlmZWn*ey^dd�Z	Gdd	�d	e
�ZYn0dS)
z�Helpers for managing cleanup functions and the errors they might raise.

This currently just contains a copy of contextlib.ExitStack, available
even on older versions of Python.
�)�absolute_import)�dequeN)�	ExitStackcCs|\}}}td�dS)Nz!raise exc_type, exc_value, exc_tb)�exec)�exc_details�exc_type�	exc_valueZexc_tb�r	�0/usr/lib/python3/dist-packages/breezy/cleanup.py�_reraise_with_existing_contextTs
rc@sXeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)ra�Context manager for dynamic management of a stack of exit callbacks

        For example:

            with ExitStack() as stack:
                files = [stack.enter_context(open(fname)) for fname in filenames]
                # All opened files will automatically be closed at the end of
                # the with statement, even if attempts to open files later
                # in the list raise an exception

        cCst�|_dS�N)r�_exit_callbacks��selfr	r	r
�__init__hszExitStack.__init__cCst|��}|j|_t�|_|S)z?Preserve the context stack by transferring it to a new instance)�typer
r)r�	new_stackr	r	r
�pop_allks
zExitStack.pop_allcs"��fdd�}�|_|�|�dS)z:Helper to correctly register callbacks to __exit__ methodscs��g|�R�Srr	)r��cm�cm_exitr	r
�
_exit_wrappertsz.ExitStack._push_cm_exit.<locals>._exit_wrapperN)�__self__�push)rrrrr	rr
�
_push_cm_exitrszExitStack._push_cm_exitcCsBt|�}z
|j}Wnty0|j�|�Yn0|�||�|S)aRegisters a callback with the standard __exit__ method signature

            Can suppress exceptions the same way __exit__ methods can.

            Also accepts any object with an __exit__ method (registering a call
            to the method instead of the object itself)
            )r�__exit__�AttributeErrorr
�appendr)r�exit�_cb_type�exit_methodr	r	r
rys

zExitStack.pushcs$���fdd�}�|_|�|��S)zdRegisters an arbitrary callback and arguments.

            Cannot suppress exceptions.
            cs��i���dSrr	)r�exc�tb��args�callback�kwdsr	r
r�sz)ExitStack.callback.<locals>._exit_wrapper)�__wrapped__r)rr%r$r&rr	r#r
r%�s
zExitStack.callbackcCs(t|�}|j}|�|�}|�||�|S)z�Enters the supplied context manager

            If successful, also pushes its __exit__ method as a callback and
            returns the result of the __enter__ method.
            )rr�	__enter__r)rr�_cm_type�_exit�resultr	r	r
�
enter_context�s

zExitStack.enter_contextcCs|�ddd�dS)z$Immediately unwind the context stackN)rrr	r	r
�close�szExitStack.closecCs|Srr	rr	r	r
r(�szExitStack.__enter__c
Gs�|ddu}t��d}dd�}||�}d}d}|jr�|j��}z||�rVd}d}d}Wq0t��}	||	d|d�d}|	}Yq00q0|r�t|�|o�|S)Nr�cSsdd�S)NcSsdSrr	)�new_exc�old_excr	r	r
�<lambda>��zAExitStack.__exit__.<locals>._make_context_fixer.<locals>.<lambda>r	)�	frame_excr	r	r
�_make_context_fixer�sz/ExitStack.__exit__.<locals>._make_context_fixerFT)NNN)�sys�exc_infor
�popr)
rr�received_excr3r4�_fix_exception_context�suppressed_exc�
pending_raise�cb�new_exc_detailsr	r	r
r�s*
zExitStack.__exit__N)
�__name__�
__module__�__qualname__�__doc__rrrrr%r,r-r(rr	r	r	r
r\s

r)rAZ
__future__r�collectionsrr5�
contextlibr�ImportErrorr�objectr	r	r	r
�<module>s5