%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/pyudev/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/pyudev/__pycache__/core.cpython-312.pyc

�

W	�c�3���dZddlmZmZddlmZddlmZddlm	Z	m
Z
mZmZddl
mZGd�de�ZGd	�d
e�Zy)z�
    pyudev.core
    ===========

    Core types and functions of :mod:`pyudev`.

    .. moduleauthor::  Sebastian Wiesner  <lunaryorn@gmail.com>
�)�ERROR_CHECKERS�
SIGNATURES)�load_ctypes_library)�DeviceNotFoundAtPathError)�ensure_byte_string�ensure_unicode_string�property_value_to_bytes�udev_list_iterate)�Devicesc��eZdZdZd�Zd�Zed��Zed��Zed��Z	ed��Z
e
jd��Z
d	�Zy
)�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�v�tdtt�|_|jj	�|_y)z'
        Create a new context.
        zlibudev.so.1N)rrr�_libudev�udev_new�_as_parameter_��selfs �-/usr/lib/python3/dist-packages/pyudev/core.py�__init__zContext.__init__7s)��,�N�J��W��
�"�m�m�4�4�6���c�T�t|d�r|jj|�yy)Nr)�hasattrr�
udev_unrefrs r�__del__zContext.__del__>s#���4��$��M�M�$�$�T�*�%rc�x�t|jd�r$t|jj|��Sy)zV
        The ``sysfs`` mount point defaulting to ``/sys'`` as unicode string.
        �udev_get_sys_pathz/sys)rrrrrs r�sys_pathzContext.sys_pathB�0��
�4�=�=�"5�6�(����)H�)H��)N�O�O�rc�x�t|jd�r$t|jj|��Sy)zU
        The device directory path defaulting to ``/dev`` as unicode string.
        �udev_get_dev_pathz/dev)rrrr rs r�device_pathzContext.device_pathKrrc�x�t|jd�r$t|jj|��Sy)z�
        The run runtime directory path defaulting to ``/run`` as unicode
        string.

        .. udevversion:: 167

        .. versionadded:: 0.10
        �udev_get_run_pathz	/run/udev)rrrr#rs r�run_pathzContext.run_pathTs0���4�=�=�"5�6�(����)H�)H��)N�O�O�rc�8�|jj|�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�udev_get_log_priorityrs r�log_priorityzContext.log_prioritybs��"�}�}�2�2�4�8�8rc�<�|jj||�y)zT
        Set the log priority.

        :param int value: the log priority.
        N)r�udev_set_log_priority)r�values  rr'zContext.log_priorityus��	
�
�
�+�+�D�%�8rc�8�t|�jdi|��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�kwargss  r�list_deviceszContext.list_devices~s��&�z�$��%�%�/��/�/rN)
�__name__�
__module__�__qualname__�__doc__rr�propertyrr!r$r'�setterr0r,rrr
r
's���
�7�+��������������9��9�$���9��9�0rr
c�V�eZdZdZd�Zd�Zd�Zdd�Zd�Zd�Z	dd�Z
d	�Zd
�Zd�Z
d�Zy
)r-a�
    A filtered iterable of devices.

    To retrieve devices, simply iterate over an instance of this class.
    This operation yields :class:`Device` objects representing the available
    devices.

    Before iteration the device list can be filtered by subsystem or by
    property values using :meth:`match_subsystem` and
    :meth:`match_property`.  Multiple subsystem (property) filters are
    combined using a logical OR, filters of different types are combined
    using a logical AND.  The following filter for instance::

        devices.match_subsystem('block').match_property(
            'ID_TYPE', 'disk').match_property('DEVTYPE', 'disk')

    means the following::

        subsystem == 'block' and (ID_TYPE == 'disk' or DEVTYPE == 'disk')

    Once added, a filter cannot be removed anymore.  Create a new object
    instead.

    Instances of this class can directly be given as given ``udev_enumerate *``
    to functions wrapped through :mod:`ctypes`.
    c��t|t�std��||_|jj|�|_|j|_y)z�
        Create a new enumerator with the given ``context`` (a
        :class:`Context` instance).

        While you can create objects of this class directly, this is not
        recommended.  Call :method:`Context.list_devices()` instead.
        zInvalid context objectN)�
isinstancer
�	TypeError�contextr�udev_enumerate_newr)rr;s  rrzEnumerator.__init__�sG���'�7�+��4�5�5����%�.�.�A�A�'�J����(�(��
rc�:�|jj|�y)N)r�udev_enumerate_unrefrs rrzEnumerator.__del__�s���
�
�*�*�4�0rc��|jdd�}|�|j|�|jdd�}|�|j|�|jdd�}|�|j|�|jdd�}|�|j	|�|j�D]\}}|j
||��|S)a2
        Include devices according to the rules defined by the keyword
        arguments.  These keyword arguments are interpreted as follows:

        - The value for the keyword argument ``subsystem`` is forwarded to
          :meth:`match_subsystem()`.
        - The value for the keyword argument ``sys_name`` is forwared to
          :meth:`match_sys_name()`.
        - The value for the keyword argument ``tag`` is forwared to
          :meth:`match_tag()`.
        - The value for the keyword argument ``parent`` is forwared to
          :meth:`match_parent()`.
        - All other keyword arguments are forwareded one by one to
          :meth:`match_property()`.  The keyword argument itself is interpreted
          as property name, the value of the keyword argument as the property
          value.

        All keyword arguments are optional, calling this method without no
        arguments at all is simply a noop.

        Return the instance again.

        .. versionadded:: 0.8

        .. versionchanged:: 0.13
           Add ``parent`` keyword.
        �	subsystemN�sys_name�tag�parent)�pop�match_subsystem�match_sys_name�	match_tag�match_parent�items�match_property)rr/r@rArBrC�propr*s        rr.zEnumerator.match�s���8�J�J�{�D�1�	�� �� � ��+��:�:�j�$�/��������)��j�j���%���?��N�N�3�����H�d�+�������f�%�!�<�<�>�	-�K�D�%�����e�,�	-��rc��|r|jjn|jj}||t|��|S)a$
        Include all devices, which are part of the given ``subsystem``.

        ``subsystem`` is either a unicode string or a byte string, containing
        the name of the subsystem.  If ``nomatch`` is ``True`` (default is
        ``False``), the match is inverted:  A device is only included if it is
        *not* part of the given ``subsystem``.

        Note that, if a device has no subsystem, it is not included either
        with value of ``nomatch`` True or with value of ``nomatch`` False.

        Return the instance again.
        )r�$udev_enumerate_add_nomatch_subsystem�"udev_enumerate_add_match_subsystemr)rr@�nomatchr.s    rrEzEnumerator.match_subsystem�s?�� �
�M�M�>�>����A�A�	�
	�d�&�y�1�2��rc�P�|jj|t|��|S)z�
        Include all devices with the given name.

        ``sys_name`` is a byte or unicode string containing the device name.

        Return the instance again.

        .. versionadded:: 0.8
        )r� udev_enumerate_add_match_sysnamer)rrAs  rrFzEnumerator.match_sys_name�s(��	
�
�
�6�6��$�X�.�	
��rc�d�|jj|t|�t|��|S)a�
        Include all devices, whose ``prop`` has the given ``value``.

        ``prop`` is either a unicode string or a byte string, containing
        the name of the property to match.  ``value`` is a property value,
        being one of the following types:

        - :func:`int`
        - :func:`bool`
        - A byte string
        - Anything convertable to a unicode string (including a unicode string
          itself)

        Return the instance again.
        )r�!udev_enumerate_add_match_propertyrr	)rrKr*s   rrJzEnumerator.match_propertys0�� 	
�
�
�7�7��$�T�*�,C�E�,J�	
��rc��|s|jjn|jj}||t|�t	|��|S)a�
        Include all devices, whose ``attribute`` has the given ``value``.

        ``attribute`` is either a unicode string or a byte string, containing
        the name of a sys attribute to match.  ``value`` is an attribute value,
        being one of the following types:

        - :func:`int`,
        - :func:`bool`
        - A byte string
        - Anything convertable to a unicode string (including a unicode string
          itself)

        If ``nomatch`` is ``True`` (default is ``False``), the match is
        inverted:  A device is include if the ``attribute`` does *not* match
        the given ``value``.

        .. note::

           If ``nomatch`` is ``True``, devices which do not have the given
           ``attribute`` at all are also included.  In other words, with
           ``nomatch=True`` the given ``attribute`` is *not* guaranteed to
           exist on all returned devices.

        Return the instance again.
        )r� udev_enumerate_add_match_sysattr�"udev_enumerate_add_nomatch_sysattrrr	)r�	attributer*rOr.s     r�match_attributezEnumerator.match_attribute#sG��:�
�M�M�:�:����A�A�	�
	�d�&�y�1�3J�5�3Q�R��rc�P�|jj|t|��|S)z�
        Include all devices, which have the given ``tag`` attached.

        ``tag`` is a byte or unicode string containing the tag name.

        Return the instance again.

        .. udevversion:: 154

        .. versionadded:: 0.6
        )r�udev_enumerate_add_match_tagr)rrBs  rrGzEnumerator.match_tagFs#��	
�
�
�2�2�4�9K�C�9P�Q��rc�<�|jj|�|S)a�
        Include only devices, which are initialized.

        Initialized devices have properly set device node permissions and
        context, and are (in case of network devices) fully renamed.

        Currently this will not affect devices which do not have device nodes
        and are not network interfaces.

        Return the instance again.

        .. seealso:: :attr:`Device.is_initialized`

        .. udevversion:: 165

        .. versionadded:: 0.8
        )r�'udev_enumerate_add_match_is_initializedrs r�match_is_initializedzEnumerator.match_is_initializedUs��$	
�
�
�=�=�d�C��rc�>�|jj||�|S)a 
        Include all devices on the subtree of the given ``parent`` device.

        The ``parent`` device itself is also included.

        ``parent`` is a :class:`~pyudev.Device`.

        Return the instance again.

        .. udevversion:: 172

        .. versionadded:: 0.13
        )r�udev_enumerate_add_match_parent)rrCs  rrHzEnumerator.match_parentjs��	
�
�
�5�5�d�F�C��rc#�K�|jj|�|jj|�}t|j|�D](\}}	t	j
|j|����*y#t$rY�7wxYw�w)z\
        Iterate over all matching devices.

        Yield :class:`Device` objects.
        N)r�udev_enumerate_scan_devices�udev_enumerate_get_list_entryr
r�
from_sys_pathr;r)r�entry�name�_s    r�__iter__zEnumerator.__iter__{s{����	
�
�
�1�1�$�7��
�
�;�;�D�A��(�����>�	�G�D�!�
��+�+�D�L�L�$�?�?�	��-�
��
�s*�AB
�"A;�8B
�;	B�B
�B�B
N)F)r1r2r3r4rrr.rErFrJrXrGr]rHrgr,rrr-r-�s@���6)�1�*�X�,
��*!�F
��*�"rr-N)r4�pyudev._ctypeslib.libudevrr�pyudev._ctypeslib.utilsr�pyudev._errorsr�pyudev._utilrrr	r
�
pyudev.devicer�objectr
r-r,rr�<module>rnsB��"�A�7�4���"�f0�f�f0�Rw��wr

Zerion Mini Shell 1.0