Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/oslo_utils/__pycache__/excutils.cpython-39.pyc
Ðазад
a s�h�8 � @ s� d Z ddlZddlZddlZddlZddlZddlZddlZddlm Z ddlm Z ddlmZ G dd� de�Z dd � ZG d d� de�Zdd � ZG dd� de�ZdS )z Exception related utilities. � N)�encodeutils)� reflection)� timeutilsc sD e Zd ZdZd� fdd� Zdd� Zdd� Zd d � Zddd�Z� Z S )�CausedByExceptiona Base class for exceptions which have associated causes. NOTE(harlowja): in later versions of python we can likely remove the need to have a ``cause`` here as PY3+ have implemented :pep:`3134` which handles chaining in a much more elegant manner. :param message: the exception message, typically some string that is useful for consumers to view when debugging or analyzing failures. :param cause: the cause of the exception being raised, when provided this should itself be an exception instance, this is useful for creating a chain of exceptions for versions of python where this is not yet implemented/supported natively. .. versionadded:: 2.4 Nc s t t| ��|� || _d S �N)�superr �__init__�cause)�self�messager �� __class__� ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/oslo_utils/excutils.pyr 3 s zCausedByException.__init__c C s | � � �d�S )N�utf8)�pformat�encode�r r r r � __bytes__7 s zCausedByException.__bytes__c C s | � � S r )r r r r r �__str__: s zCausedByException.__str__c C s | j d S )Nr )�argsr r r r �_get_message= s zCausedByException._get_message� � Fc C sZ |dk rt d| ��t�� }|r>|�tj| dd�� |�d� |�| �� � |}| j}g }|du�rR||v�rR|�|� |�t j � t|t�r�|�|| � |�tj|dd�� |�d� |�|�� � nrt �t|�|�}t|�D ]T\} } |�|| � | �d��r| dd� } |�| � | d t|�kr�|�t j � q�qR||7 }t|d d�}qZ|�� S )z9Pretty formats a caused exception + any connected causes.r zEProvided 'indent' must be greater than or equal to zero instead of %sF)Zfully_qualifiedz: N� ���� r )� ValueError�io�StringIO�writer Zget_class_namer r �append�os�linesep� isinstancer � traceback�format_exception_only�type� enumerate�endswith�len�getattr�getvalue)r �indentZindent_textZshow_root_class�bufZ active_indentZnext_up�seen�lines�i�liner r r r C sD � � zCausedByException.pformat)N)r r F) �__name__� __module__�__qualname__�__doc__r r r r r � __classcell__r r r r r "