o
    8g+^[                     @   s   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlZddlmZ eej	G dd	 d	e
Zeej	G d
d deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZdS )z
    pyudev.device._errors
    =====================

    Errors raised by Device methods.

    .. moduleauthor:: Sebastian Wiesner <lunaryorn@gmail.com>
    )absolute_import)division)print_function)unicode_literalsN)add_metaclassc                   @      e Zd ZdZdS )DeviceErrorzP
    Any error raised when messing around w/ or trying to discover devices.
    N__name__
__module____qualname____doc__ r   r   0/usr/lib/python3/dist-packages/pyudev/_errors.pyr   $       r   c                   @   r   )DeviceNotFoundErrorz
    An exception indicating that no :class:`Device` was found.

    .. versionchanged:: 0.5
       Rename from ``NoSuchDeviceError`` to its current name.
    Nr	   r   r   r   r   r   +   r   r   c                   @   s,   e Zd ZdZdd Zedd Zdd ZdS )	DeviceNotFoundAtPathErrorzh
    A :exc:`DeviceNotFoundError` indicating that no :class:`Device` was
    found at a given path.
    c                 C   s   t | | d S Nr   __init__)selfsys_pathr   r   r   r   ;   s   z"DeviceNotFoundAtPathError.__init__c                 C   
   | j d S )z<
        The path that caused this error as string.
        r   argsr   r   r   r   r   >      
z"DeviceNotFoundAtPathError.sys_pathc                 C   s   d | jS )NzNo device at {0!r})formatr   r   r   r   r   __str__E   s   z!DeviceNotFoundAtPathError.__str__N)r
   r   r   r   r   propertyr   r   r   r   r   r   r   5   s    
r   c                   @   r   )DeviceNotFoundByFileErrorzp
    A :exc:`DeviceNotFoundError` indicating that no :class:`Device` was
    found from the given filename.
    Nr	   r   r   r   r   r    I       r    c                   @   r   )#DeviceNotFoundByInterfaceIndexErrorzw
    A :exc:`DeviceNotFoundError` indicating that no :class:`Device` was found
    from the given interface index.
    Nr	   r   r   r   r   r"   P   r!   r"   c                   @   r   )!DeviceNotFoundByKernelDeviceErrorz
    A :exc:`DeviceNotFoundError` indicating that no :class:`Device` was found
    from the given kernel device string.

    The format of the kernel device string is defined in the
    systemd.journal-fields man pages.
    Nr	   r   r   r   r   r#   W   r!   r#   c                   @   8   e Zd ZdZdd Zedd Zedd Zdd	 Zd
S )DeviceNotFoundByNameErrorzj
    A :exc:`DeviceNotFoundError` indicating that no :class:`Device` was
    found with a given name.
    c                 C      t | || d S r   r   )r   	subsystemsys_namer   r   r   r   g      z"DeviceNotFoundByNameError.__init__c                 C   r   )zA
        The subsystem that caused this error as string.
        r   r   r   r   r   r   r'   j   r   z#DeviceNotFoundByNameError.subsystemc                 C   r   )z@
        The sys name that caused this error as string.
           r   r   r   r   r   r(   q   r   z"DeviceNotFoundByNameError.sys_namec                 C   
   d | S )Nz+No device {0.sys_name!r} in {0.subsystem!r}r   r   r   r   r   r   x   s   
z!DeviceNotFoundByNameError.__str__N)	r
   r   r   r   r   r   r'   r(   r   r   r   r   r   r%   a   s    

r%   c                   @   r$   )DeviceNotFoundByNumberErrorzs
    A :exc:`DeviceNotFoundError` indicating, that no :class:`Device` was found
    for a given device number.
    c                 C   r&   r   r   )r   typnumberr   r   r   r      r)   z$DeviceNotFoundByNumberError.__init__c                 C   r   )zj
        The device type causing this error as string.  Either ``'char'`` or
        ``'block'``.
        r   r   r   r   r   r   device_type   s   
z'DeviceNotFoundByNumberError.device_typec                 C   r   )zB
        The device number causing this error as integer.
        r*   r   r   r   r   r   device_number   r   z)DeviceNotFoundByNumberError.device_numberc                 C   r+   )Nz7No {0.device_type} device with number {0.device_number}r,   r   r   r   r   r      s   z#DeviceNotFoundByNumberError.__str__N)	r
   r   r   r   r   r   r0   r1   r   r   r   r   r   r-   |   s    

r-   c                   @   s   e Zd ZdZdd ZdS ) DeviceNotFoundInEnvironmentErrorz
    A :exc:`DeviceNotFoundError` indicating, that no :class:`Device` could
    be constructed from the process environment.
    c                 C   s   dS )NzNo device found in environmentr   r   r   r   r   r      s   z(DeviceNotFoundInEnvironmentError.__str__N)r
   r   r   r   r   r   r   r   r   r2      s    r2   c                   @   s&   e Zd ZdZdZdddZdd ZdS )	DeviceValueErrorz
    Raised when a parameter has an unacceptable value.

    May also be raised when the parameter has an unacceptable type.
    z+value '%s' for parameter %s is unacceptableNc                 C   s   || _ || _|| _dS )z Initializer.

            :param object value: the value
            :param str param: the parameter
            :param str msg: an explanatory message
        N)_value_param_msg)r   valueparammsgr   r   r   r      s   
zDeviceValueError.__init__c                 C   s6   | j r| jd }|| j| j| j f S | j| j| jf S )Nz: %s)r6   _FMT_STRr4   r5   )r   fmt_strr   r   r   r      s   
zDeviceValueError.__str__r   )r
   r   r   r   r:   r   r   r   r   r   r   r3      s
    
r3   )r   
__future__r   r   r   r   abcsixr   ABCMeta	Exceptionr   r   r   r    r"   r#   r%   r-   r2   r3   r   r   r   r   <module>   s&   		

