File: //proc/10488/root/lib/python3.9/site-packages/pyudev/__pycache__/core.cpython-39.pyc
a
8g+^?4 � @ s� d Z ddlmZmZmZmZ ddlmZ ddlm Z ddl
mZ ddl
mZ ddl
mZ ddlmZ dd lmZ dd
lmZ ddlmZ G dd
� d
e�ZG dd� de�ZdS )z�
pyudev.core
===========
Core types and functions of :mod:`pyudev`.
.. moduleauthor:: Sebastian Wiesner <lunaryorn@gmail.com>
� )�print_function�division�unicode_literals�absolute_import)�Devices)�DeviceNotFoundAtPathError)�ERROR_CHECKERS)�
SIGNATURES)�load_ctypes_library)�ensure_byte_string)�ensure_unicode_string)�property_value_to_bytes)�udev_list_iteratec @ sf e Zd ZdZdd� Zdd� Zedd� �Zedd � �Zed
d� �Z edd
� �Z
e
jdd
� �Z
dd� ZdS )�Contexta
A device database connection.
This class represents a connection to the udev device database, and is
really *the* central object to access udev. You need an instance of this
class for almost anything else in pyudev.
This class itself gives access to various udev configuration data (e.g.
:attr:`sys_path`, :attr:`device_path`), and provides device enumeration
(:meth:`list_devices()`).
Instances of this class can directly be given as ``udev *`` to functions
wrapped through :mod:`ctypes`.
c C s t dtt�| _| j�� | _dS )z'
Create a new context.
ZudevN)r
r r �_libudevZudev_new�_as_parameter_��self� r �//usr/lib/python3.9/site-packages/pyudev/core.py�__init__9 s zContext.__init__c C s | j �| � d S �N)r Z
udev_unrefr r r r �__del__@ s zContext.__del__c C s t | jd�rt| j�| ��S dS )zV
The ``sysfs`` mount point defaulting to ``/sys'`` as unicode string.
�udev_get_sys_pathz/sys)�hasattrr r r r r r r �sys_pathC s zContext.sys_pathc C s t | jd�rt| j�| ��S dS )zU
The device directory path defaulting to ``/dev`` as unicode string.
�udev_get_dev_pathz/dev)r r r r r r r r �device_pathL s zContext.device_pathc C s t | jd�rt| j�| ��S dS )z�
The run runtime directory path defaulting to ``/run`` as unicode
string.
.. udevversion:: 167
.. versionadded:: 0.10
�udev_get_run_pathz /run/udev)r r r r r r r r �run_pathU s
zContext.run_pathc C s | j �| �S )a
The logging priority of the interal logging facitility of udev as
integer with a standard :mod:`syslog` priority. Assign to this
property to change the logging priority.
UDev uses the standard :mod:`syslog` priorities. Constants for these
priorities are defined in the :mod:`syslog` module in the standard
library:
>>> import syslog
>>> context = pyudev.Context()
>>> context.log_priority = syslog.LOG_DEBUG
.. versionadded:: 0.9
)r Zudev_get_log_priorityr r r r �log_priorityc s zContext.log_priorityc C s | j �| |� dS )zT
Set the log priority.
:param int value: the log priority.
N)r Zudev_set_log_priority)r �valuer r r r v s c K s t | �jf i |��S )a"
List all available devices.
The arguments of this method are the same as for
:meth:`Enumerator.match()`. In fact, the arguments are simply passed
straight to method :meth:`~Enumerator.match()`.
This function creates and returns an :class:`Enumerator` object,
that can be used to filter the list of devices, and eventually
retrieve :class:`Device` objects representing matching devices.
.. versionchanged:: 0.8
Accept keyword arguments now for easy matching.
)�
Enumerator�match)r �kwargsr r r �list_devices s zContext.list_devicesN)
�__name__�
__module__�__qualname__�__doc__r r �propertyr r r r �setterr% r r r r r ) s
r c @ sl e Zd ZdZdd� Zdd� Zdd� Zdd d
�Zdd� Zd
d� Z ddd�Z
dd� Zdd� Zdd� Z
dd� ZdS )r"