Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/pyudev/__pycache__/discover.cpython-39.pyc
Ðазад
a i�h�, � @ s� d Z ddlmZmZmZmZ ddlZddlZddlZddl Z ddl Z ddlmZ ddl mZ dd� Ze �ej�G dd � d e��ZG d d� de�ZG dd � d e�ZG dd� de�ZG dd� de�ZG dd� de�ZdS )z� pyudev.discover =============== Tools to discover a device given limited information. .. moduleauthor:: mulhern <amulhern@redhat.com> � )�absolute_import�division�print_function�unicode_literalsN��DeviceNotFoundError)�Devicesc s t �� �� fdd��}|S )z\ Allow Device discovery methods to return None instead of raising an exception. c s* z� | i |��W S t y$ Y dS 0 dS )z� Returns result of calling ``func`` on ``args``, ``kwargs``. Returns None if ``func`` raises :exc:`DeviceNotFoundError`. Nr )�args�kwargs��func� �/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/pyudev/discover.py�the_func1 s z wrap_exception.<locals>.the_func)� functools�wraps)r r r r r �wrap_exception+ s r c @ sL e Zd ZdZeejdd� ��Zeejdd� ��Zedd� �Z edd � �Z d S )� HypothesiszM Represents a hypothesis about the meaning of the device identifier. c C s t � �dS )a� Match the given string according to the hypothesis. The purpose of this method is to obtain a value corresponding to ``value`` if that is possible. It may use a regular expression, but in general it should just return ``value`` and let the lookup method sort out the rest. :param str value: the string to inspect :returns: the matched thing or None if unmatched :rtype: the type of lookup's key parameter or NoneType N��NotImplementedError��cls�valuer r r �matchE s zHypothesis.matchc C s t � �dS )aN Lookup the given string according to the hypothesis. :param Context context: the pyudev context :param key: a key with which to lookup the device :type key: the type of match's return value if not None :returns: a list of Devices obtained :rtype: frozenset of :class:`Device` Nr )r �context�keyr r r �lookupV s zHypothesis.lookupc C s dS )z� A potentially expensive method that may allow an :class:`Hypothesis` to find devices more rapidly or to find a device that it would otherwise miss. :param Context context: the pyudev context Nr �r r r r r �setupd s zHypothesis.setupc C s$ | � |�}|dur| �||�S t� S )a Get any devices that may correspond to the given string. :param Context context: the pyudev context :param str value: the value to look for :returns: a list of devices obtained :rtype: set of :class:`Device` N)r r � frozenset)r r r r r r r �get_deviceso s zHypothesis.get_devicesN)�__name__� __module__�__qualname__�__doc__�classmethod�abc�abstractmethodr r r r r r r r r ? s r c @ sL e Zd ZdZedd� �Zedd� �Zedd� �Zedd � �Zed d� �Z dS ) �DeviceNumberHypothesisz� Represents the hypothesis that the device is a device number. The device may be separated into major/minor number or a composite number. c C s8 t �d�}|�|�}|o6t�t|�d��t|�d���S )z� Match the number under the assumption that it is a major,minor pair. :param str value: value to match :returns: the device number or None :rtype: int or NoneType z#^(?P<major>\d+)(\D+)(?P<minor>\d+)$�major�minor)�re�compiler �os�makedev�int�group)r r Zmajor_minor_rer r r r �_match_major_minor� s �z)DeviceNumberHypothesis._match_major_minorc C s&