o
    VAfî  ã                   @   s<   d dl ZG dd„ deƒZG dd„ deƒZG dd„ deƒZdS )é    Nc                   @   s$   e Zd ZdZdd„ Zedd„ ƒZdS )ÚDevicezƒ
		This is an abstract class that represents all devices in the system.
		Every single device has its own instance of this class.
	c                 C   sr   || _ i | _ttj  |d¡ƒ }| ¡ D ]}| d¡\}}| ¡  ¡ | j|< qW d  ƒ dS 1 s2w   Y  dS )z_
			Collect all information about the device by reading the
			"uevent" file and parsing it.
		Zueventú=N)	ÚpathÚ_ueventÚopenÚosÚjoinÚ	readlinesÚsplitÚrstripÚlower)Úselfr   ÚfÚlineÚkeyÚval© r   ú4/usr/lib/python3.10/site-packages/fireinfo/device.pyÚ__init__   s   þ"ÿzDevice.__init__c                 C   ó   | j  dd¡S )zL
			Get the driver/kernel module that device is driven by or return None.
		ZDRIVERN©r   Úget©r   r   r   r   Údriver0   ó   zDevice.driverN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr   r   r   r   r   r      s
    r   c                   @   sP   e Zd ZdZdZedd„ ƒZedd„ ƒZedd„ ƒZed	d
„ ƒZ	edd„ ƒZ
dS )Ú	PCIDevicezD
		A class that represents all PCI (and PCIe) devices in a system.
	Zpcic                 C   ó   | j d  d¡d S )z.
			Return the PCI model id of this device.
		ÚPCI_IDú:é   ©r   r
   r   r   r   r   Úmodel?   ó   zPCIDevice.modelc                 C   r!   )z/
			Return the PCI vendor id of this device.
		r"   r#   r   r%   r   r   r   r   ÚvendorF   r'   zPCIDevice.vendorc                 C   s
   | j d S )z2
			Return the PCI device class of this device.
		Z	PCI_CLASS)r   r   r   r   r   ÚdeviceclassM   s   
zPCIDevice.deviceclassc                 C   r!   )z3
			Return the PCI vendor sub id of this device.
		ÚPCI_SUBSYS_IDr#   r   r%   r   r   r   r   Ú
sub_vendorT   r'   zPCIDevice.sub_vendorc                 C   r!   )z2
			Return the PCI model sub id of this device.
		r*   r#   r$   r%   r   r   r   r   Ú	sub_model[   r'   zPCIDevice.sub_modelN)r   r   r   r   Ú	subsystemr   r&   r(   r)   r+   r,   r   r   r   r   r    8   s    



r    c                   @   s@   e Zd ZdZdZdd„ Zedd„ ƒZedd„ ƒZed	d
„ ƒZ	dS )Ú	USBDevicez9
		A class that represents all USB devices in a system.
	Zusbc                 C   s$   t |ƒdk rd| }t |ƒdk s|S )z9
			A function to pad ids that have no leading zeroes.
		é   Ú0)Úlen)r   Úsr   r   r   Úpadj   s   ÿzUSBDevice.padc                 C   ó   |   | jd  d¡d ¡S )z/
			Return the USB vendor id of this device.
		ÚPRODUCTú/r   ©r3   r   r
   r   r   r   r   r(   r   ó   zUSBDevice.vendorc                 C   r4   )z.
			Return the USB model id of this device.
		r5   r6   r$   r7   r   r   r   r   r&   y   r8   zUSBDevice.modelc                 C   r   )z2
			Return the USB device class of this device.
		Z	INTERFACENr   r   r   r   r   r)   €   r   zUSBDevice.deviceclassN)
r   r   r   r   r-   r3   r   r(   r&   r)   r   r   r   r   r.   c   s    

r.   )Zos.pathr   Úobjectr   r    r.   r   r   r   r   Ú<module>   s    +