File: //lib64/python3.9/site-packages/gpg/__pycache__/errors.cpython-39.pyc
a
    e�\c  �                   @   s  d dl mZmZmZ ddlmZ ddlmZ [[[dZdZe�	de
� � [G dd� de�ZG d	d
� d
e�Z
d!dd�ZG d
d� de
e�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd � d e�ZdS )"�    )�absolute_import�print_function�unicode_literals�   )�gpgme)�utilNZGPG_ERR_c                   @   sR   e Zd ZdZddd�Zedd� �Zedd� �Zed	d
� �Zedd� �Z	d
d� Z
dS )�GpgErrora>  A GPG Error
    This is the base of all errors thrown by this library.
    If the error originated from GPGME, then additional information
    can be found by looking at 'code' for the error code, and 'source'
    for the errors origin.  Suitable constants for comparison are
    defined in this module.  'code_str' and 'source_str' are
    human-readable versions of the former two properties.
    If 'context' is not None, then it contains a human-readable hint
    as to where the error originated from.
    If 'results' is not None, it is a tuple containing results of the
    operation that failed.  The tuples elements are the results of the
    function that raised the error.  Some operations return results
    even though they signal an error.  Of course this information must
    be taken with a grain of salt.  But often, this information is
    useful for diagnostic uses or to give the user feedback.  Since
    the normal control flow is disrupted by the exception, the callee
    can no longer return results, hence we attach them to the
    exception objects.
    Nc                 C   s   || _ || _|| _d S �N)�error�context�results)�selfr
   r   r   � r   �0/usr/lib64/python3.9/site-packages/gpg/errors.py�__init__=   s    zGpgError.__init__c                 C   s   | j d u rd S t�| j �S r	   )r
   r   Zgpgme_err_code�r
   r   r   r   �codeB   s    
z
GpgError.codec                 C   s   | j d u rd S t�| j �S r	   )r
   r   �gpgme_strerrorr   r   r   r   �code_strH   s    
zGpgError.code_strc                 C   s   | j d u rd S t�| j �S r	   )r
   r   Zgpgme_err_sourcer   r   r   r   �sourceN   s    
zGpgError.sourcec                 C   s   | j d u rd S t�| j �S r	   )r
   r   Zgpgme_strsourcer   r   r   r   �
source_strT   s    
zGpgError.source_strc                 C   sF   g }| j d ur|�| j � | jd ur<|�| j� |�| j� d�|�S )Nz: )r   �appendr
   r   r   �join)r
   Zmsgsr   r   r   �__str__Z   s    
zGpgError.__str__)NNN)�__name__�
__module__�__qualname__�__doc__r   �propertyr   r   r   r   r   r   r   r   r   r   #   s   
r   c                   @   s@   e Zd ZdZedd� �Zedd� �Zdd� Zdd	� Z	d
d� Z
dS )
�
GPGMEErrorz�Generic error
    This is a generic error that wraps the underlying libraries native
    error type.  It is thrown when the low-level API is invoked and
    returns an error.  This is the error that was used in PyME.
    c                 C   s   | t �� �S r	   )r   Zgpgme_err_code_from_syserror)�clsr   r   r   �fromSyserrorm   s    zGPGMEError.fromSyserrorc                 C   s   | j S r	   )r   r   r   r   r   �messageq   s    zGPGMEError.messagec                 C   s   t | �S r	   )�strr   r   r   r   �	getstringu   s    zGPGMEError.getstringc                 C   s   | j S r	   )r   r   r   r   r   �getcodex   s    zGPGMEError.getcodec                 C   s   | j S r	   )r   r   r   r   r   �	getsource{   s    zGPGMEError.getsourceN)r   r   r   r   �classmethodr!   r   r"