Sindbad~EG File Manager

Current Path : /lib/python3.6/site-packages/vdo/utils/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/vdo/utils/__pycache__/Transaction.cpython-36.pyc

3

x?ag��@s�dZddlmZddlmZddlmZddlmZddlmZddlZddl	Z	ddl
Z
ejd�e	jdkrvd
d�Z
ned�Gd
d�de�Zdd�ZdS)z}
  Transaction - provides transactional support

  $Id: //eng/vdo-releases/aluminum/src/python/vdo/utils/Transaction.py#1 $

�)�absolute_import)�division)�print_function)�unicode_literals)�wrapsN�Transaction�cCs|j|��dS)N)�with_traceback)�ex�val�tb�r
�!/usr/lib/python3.6/Transaction.py�reraise'srz:def reraise(ex, val, tb):
    raise type(ex), val, tb
    csVeZdZdZiZedd��Zdd�Zddd�Z�fd	d
�Z	edd��Z
d
d�Z�ZS)rz%Client-visible transaction object.
  cCs|j�dS)z<Returns the current transaction for the current thread.
    ����)�_threadTransactionList)�clsr
r
r�transaction;szTransaction.transactioncCs|jj|�dS)z�Adds callable undoStage to transaction stages.

       Arguments:
        undoStage (callable)        - callable to execute as part of
                                      transaction roll-back
    N)�_Transaction__undoStages�append)�self�	undoStager
r
r�addUndoStageBszTransaction.addUndoStageNcCst�dS)a+Sets the message to handle if there is an exception.

       If message is specified and an exception occurs the exception
       will be appended to the message using "; {0}" where "{0}" represents
       the exception.

       If message is not specified, the exception will be coerced to
       a string and passed to handleMessage.

       Specifying handleMessage as None will clear both handleMessage and
       message.

       Arguments:
        handleMessage (callable)  - method to handle message
        message (string)          - message
    N)�NotImplementedError)r�
handleMessage�messager
r
r�
setMessageLszTransaction.setMessagecstt|�j�g|_dS)N)�superr�__init__r)r)�	__class__r
rrbszTransaction.__init__cCsDd}tj�j}y|j|}Wn"tk
r>g}||j|<YnX|S)z�Returns the transaction list for the current thread, creating it
       if need be.

       Returns:
         list of Transactions
    N)�	threadingZ
currentThreadZident�_Transaction__transactionLists�KeyError)rZtransactionListZthreadIdr
r
rris
z"Transaction._threadTransactionListcCs|jS)zgReturns the list of undo stages for the transaction.

       Returns:
         list of undo stages
    )r)rr
r
r�_undoStages{szTransaction._undoStages)N)
�__name__�
__module__�__qualname__�__doc__r"�classmethodrrrrrr$�
__classcell__r
r
)r rr0s

cs.G�fdd�dt��t����fdd��}|S)zGMethod decorator providing transactional capabilities to the method.
  csLeZdZdZedd��Zedd��Zdd�Z��fdd	�Zd
dd�Z	�Z
S)z#transactional.<locals>._TransactionzYDecorator-local transaction object providing actual transaction
       capabilities.
    cSs|j�j|��|j�S)z`Adds, and returns, a transaction to the transaction list for the
         current thread.
      )rrr)rr
r
r�addTransaction�sz2transactional.<locals>._Transaction.addTransactioncSs|j�j�dS)zBRemoves the current transaction for for the current thread.
      N)r�pop)rr
r
r�removeTransaction�sz5transactional.<locals>._Transaction.removeTransactioncSs�|jdk	r@|jdk	r2|jtd�j|jt|���n|jt|��|j�dd�}|j�x,|D]$}y
|�Wq^tk
r�Yq^Xq^WdS)z�Performs the undo processing of the transaction.

         Exceptions from the undo stages are ignored.

         Arguments:
          exception   - the exception which resulted in undo being called
      Nz{0}; {1})�_Transaction__handleMessage�_Transaction__message�_�format�strr$�reverse�	Exception)rZ	exceptionZ
undoStagesrr
r
r�undo�s	



z(transactional.<locals>._Transaction.undocst�|�j�d|_d|_dS)N)rrr.r/)r)�_Transactionr r
rr�sz,transactional.<locals>._Transaction.__init__NcSs"||_|jdkrd|_n||_dS)N)r.r/)rrrr
r
rr�s
z.transactional.<locals>._Transaction.setMessage)N)r%r&r'r(r)r+r-r5rrr*r
)r6)r rr6�s	r6csp�j�}d}zTy�||�}Wn@tk
r\}z$|j|�t||tj�d�WYdd}~XnXWd�j�X|S)zDWrapper method providing transactional processing capabilities.
    N�)r+r4r5r�sys�exc_infor-)�args�kwargsr�resultr
)r6�funcr
r�wrap�s
*
ztransactional.<locals>.wrap)rr)r=r>r
)r6r=r�
transactional�sJr?)rr)r(Z
__future__rrrr�	functoolsr�gettextr8r!Zinstall�version_infor�exec�objectrr?r
r
r
r�<module>s


X

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists