HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.60.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Nov 5 05:00:59 EST 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //lib/python3.9/site-packages/dasbus/__pycache__/error.cpython-39.opt-1.pyc
a

װ_]"�@s�ddlmZmZddlmZgd�Zdd�ZGdd�de�ZGdd	�d	ed
�Z	Gdd�de	�Z
Gd
d�de	�ZGdd�de�Z
dS)�)�ABCMeta�abstractmethod��
get_dbus_name)�get_error_decorator�	DBusError�AbstractErrorRule�	ErrorRule�DefaultErrorRule�ErrorMappercsd�fdd�	}|S)a�Generate a decorator for DBus errors.

    Create a function for decorating Python exception classes.
    The decorator will add a new rule to the given error mapper
    that will map the class to the specified error name.

    Definition of the decorator:

    .. code-block:: python

        decorator(error_name, namespace=())

    The decorator accepts a name of the DBus error and optionally
    a namespace of the DBus name. The namespace will be used as
    a prefix of the DBus name.

    Usage:

    .. code-block:: python

        # Create an error mapper.
        error_mapper = ErrorMapper()

        # Create a decorator for DBus errors and use it to map
        # the class ExampleError to the name my.example.Error.
        dbus_error = create_error_decorator(error_mapper)

        @dbus_error("my.example.Error")
        class ExampleError(DBusError):
            pass

    :param error_mapper: an error mapper
    :return: a decorator
    �cs$tg|���R����fdd�}|S)Ncs��t|�d��|S)N)�exception_type�
error_name)�add_ruler	)�cls)�error_mapperrr�0/usr/lib/python3.9/site-packages/dasbus/error.py�	decoratedIs
�z9get_error_decorator.<locals>.decorator.<locals>.decoratedr)r�	namespacer�r)rr�	decoratorFsz&get_error_decorator.<locals>.decorator)rr)rrrrrr#s#rc@seZdZdZdS)rzA default DBus error.N)�__name__�
__module__�__qualname__�__doc__rrrrrUsrc@sDeZdZdZgZedd��Zedd��Zedd��Zedd	��Z	d
S)rz=Abstract rule for mapping a Python exception to a DBus error.cCsdS)z�Is this rule matching the given exception type?

        :param exception_type: a type of the Python error
        :return: True or False
        Nr��selfr
rrr�
match_type_szAbstractErrorRule.match_typecCsdS)z�Get a DBus name for the given exception type.

        :param exception_type: a type of the Python error
        :return: a name of the DBus error
        Nrrrrr�get_namehszAbstractErrorRule.get_namecCsdS)z�Is this rule matching the given DBus error?

        :param error_name: a name of the DBus error
        :return: True or False
        Nr�rrrrr�
match_nameqszAbstractErrorRule.match_namecCsdS)z�Get an exception type of the given DBus error.

        param error_name: a name of the DBus error
        :return: a type of the Python error
        Nrrrrr�get_typezszAbstractErrorRule.get_typeN)
rrrr�	__slots__rrrr r!rrrrrZs


r)�	metaclassc@s@eZdZdZddgZdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)r	z4Rule for mapping a Python exception to a DBus error.�_exception_type�_error_namecCs||_||_dS)aVCreate a new error rule.

        The rule will return the Python type exception_type
        for the DBue error error_name.

        The rule will return the DBue name error_name for
        the Python type exception_type

        :param exception_type: a type of the Python error
        :param error_name: a name of the DBus error
        N)r$r%)rr
rrrr�__init__�szErrorRule.__init__cCs
|j|kS)�/Is this rule matching the given exception type?�r$rrrrr�szErrorRule.match_typecCs|jS�z-Get a DBus name for the given exception type.�r%rrrrr�szErrorRule.get_namecCs
|j|kS)�+Is this rule matching the given DBus error?r*rrrrr �szErrorRule.match_namecCs|jS�z.Get an exception type of the given DBus error.r(rrrrr!�szErrorRule.get_typeN�
rrrrr"r&rrr r!rrrrr	�s�r	c@s@eZdZdZddgZdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)r
z<Default rule for mapping a Python exception to a DBus error.�
_default_type�_default_namespacecCs||_||_dS)a~Create a new default rule.

        The rule will return the Python type default_type
        for the all DBus errors.

        The rule will generate a DBus name with the prefix
        default_namespace for all Python exception types.

        :param default_type: a default type of the Python error
        :param default_namespace: a default namespace of the DBus error
        N)r.r/)r�default_type�default_namespacerrrr&�szDefaultErrorRule.__init__cCsdS)r'Trrrrrr�szDefaultErrorRule.match_typecCstg|j�|j�R�Sr))rr/rrrrrr�szDefaultErrorRule.get_namecCsdS)r+Trrrrrr �szDefaultErrorRule.match_namecCs|jSr,)r.rrrrr!�szDefaultErrorRule.get_typeNr-rrrrr
�s�r
c@sDeZdZdZdgZdd�Zed�dd�Zdd	�Zd
d�Z	dd
�Z
dS)rz3Class for mapping Python exceptions to DBus errors.�_error_rulescCsg|_|��dS)zCreate a new error mapper.N)r2�reset_rules�rrrrr&�szErrorMapper.__init__)�rulecCs|j�|�dS)z�Add a rule to the error mapper.

        The new rule will have a higher priority than
        the rules already contained in the error mapper.

        :param rule: an error rule
        :type rule: an instance of AbstractErrorRule
        N)r2�append)rr5rrrr�s	zErrorMapper.add_rulecCsg|_|�ttdd��dS)z�Reset rules in the error mapper.

        Reset the error rules to the initial state.
        All rules will be replaced with the default ones.
        )�notZknown�Error)r0r1N)r2rr
rr4rrrr3�s
�zErrorMapper.reset_rulescCs<t|j�D]}|�|�r
|�|�Sq
td�|j���dS)a#Get a DBus name of the Python exception.

        Try to find a matching rule in the error mapper.
        If a rule matches the given exception type, use
        the rule to get the name of the DBus error.

        The rules in the error mapper are processed in
        the reversed order to respect the priority of
        the rules.

        :param exception_type: a type of the Python error
        :type exception_type: a subclass of Exception
        :return: a name of the DBus error
        :raise LookupError: if no name is found
        zNo name found for '{}'.N)�reversedr2rr�LookupError�formatr)rr
r5rrr�get_error_name�s

�zErrorMapper.get_error_namecCs:t|j�D]}|�|�r
|�|�Sq
td�|���dS)a%Get a Python exception type of the DBus error.

        Try to find a matching rule in the error mapper.
        If a rule matches the given name of a DBus error,
        use the rule to get the type of a Python exception.

        The rules in the error mapper are processed in
        the reversed order to respect the priority of
        the rules.

        :param error_name: a name of the DBus error
        :return: a type of the Python exception
        :rtype: a subclass of Exception
        :raise LookupError: if no type is found
        zNo type found for '{}'.N)r9r2r r!r:r;)rrr5rrr�get_exception_types
zErrorMapper.get_exception_typeN)rrrrr"r&rrr3r<r=rrrrr�srN)�abcrrZdasbus.namespacer�__all__r�	Exceptionrrr	r
�objectrrrrr�<module>s
2*((