U
    5ýVl  ã                   @   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                   @   s   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   ú7/usr/lib/python3/dist-packages/pyudev/device/_errors.pyr   $   s   r   c                   @   s   e Zd ZdZdS )Ú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   +   s   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   s
   | j d S )z<
        The path that caused this error as string.
        r   ©Úargs©r   r   r   r   r   >   s    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                   @   s   e Zd ZdZdS )ÚDeviceNotFoundByFileErrorzp
    A :exc:`DeviceNotFoundError` indicating that no :class:`Device` was
    found from the given filename.
    Nr   r   r   r   r   r   I   s   r   c                   @   s   e Zd ZdZdS )Ú#DeviceNotFoundByInterfaceIndexErrorzw
    A :exc:`DeviceNotFoundError` indicating that no :class:`Device` was found
    from the given interface index.
    Nr   r   r   r   r   r   O   s   r   c                   @   s   e Zd ZdZdS )Ú!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 pagees.
    Nr   r   r   r   r   r   U   s   r   c                   @   s8   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   s   t  | ||¡ d S r   r   )r   Ú	subsystemÚsys_namer   r   r   r   e   s    z"DeviceNotFoundByNameError.__init__c                 C   s
   | j d S )zA
        The subsystem that caused this error as string.
        r   r   r   r   r   r   r    h   s    z#DeviceNotFoundByNameError.subsystemc                 C   s
   | j d S )z@
        The sys name that caused this error as string.
        é   r   r   r   r   r   r!   o   s    z"DeviceNotFoundByNameError.sys_namec                 C   s
   d  | ¡S )Nz+No device {0.sys_name!r} in {0.subsystem!r}©r   r   r   r   r   r   v   s    z!DeviceNotFoundByNameError.__str__N)	r	   r
   r   r   r   r   r    r!   r   r   r   r   r   r   _   s   

r   c                   @   s8   e Zd ZdZdd„ Zedd„ ƒZedd„ ƒZdd	„ Zd
S )ÚDeviceNotFoundByNumberErrorzs
    A :exc:`DeviceNotFoundError` indicating, that no :class:`Device` was found
    for a given device number.
    c                 C   s   t  | ||¡ d S r   r   )r   ÚtypZnumberr   r   r   r   €   s    z$DeviceNotFoundByNumberError.__init__c                 C   s
   | j d S )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   s
   | j d S )zB
        The device number causing this error as integer.
        r"   r   r   r   r   r   Údevice_number‹   s    z)DeviceNotFoundByNumberError.device_numberc                 C   s
   d  | ¡S )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   r&   r'   r   r   r   r   r   r$   z   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   r(   —   s   r(   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   ÚvalueZparamÚmsgr   r   r   r   ª   s    zDeviceValueError.__init__c                 C   s:   | j r$| jd }|| j| j| j f S | j| j| jf S d S )Nz: %s)r,   Ú_FMT_STRr*   r+   )r   Zfmt_strr   r   r   r   ¶   s    
zDeviceValueError.__str__)N)r	   r
   r   r   r/   r   r   r   r   r   r   r)   ¡   s   
r)   )r   Z
__future__r   r   r   r   ÚabcZsixr   ÚABCMetaÚ	Exceptionr   r   r   r   r   r   r   r$   r(   r)   r   r   r   r   Ú<module>   s$   		

