a 8g+^@sdZddlmZddlmZddlmZddlmZddlZddlmZGdd d e Z Gd d d e Z d d Z Gddde Z Gddde ZdS)z pyudev._qt_base =============== Base mixin class for Qt4,Qt5 support. .. moduleauthor:: Sebastian Wiesner )absolute_import)division)print_function)unicode_literalsN)Devicec@sBeZdZdZddZeddZejddZddZd d Z d S) MonitorObserverMixinz0 Base mixin for pyqt monitor observers. cCs2||_|||j||_|jjt|jdSN)monitorfilenoZReadnotifierZ activatedintZconnect_process_udev_event)selfr notifier_classr3/usr/lib/python3.9/site-packages/pyudev/_qt_base.py_setup_notifier+s  z$MonitorObserverMixin._setup_notifiercCs |jS)aY Whether this observer is enabled or not. If ``True`` (the default), this observer is enabled, and emits events. Otherwise it is disabled and does not emit any events. This merely reflects the state of the ``enabled`` property of the underlying :attr:`notifier`. .. versionadded:: 0.14 )r Z isEnabled)rrrrenabled1s zMonitorObserverMixin.enabledcCs|j|dSr)r Z setEnabled)rvaluerrrr?scCs$|jjdd}|dur ||dS)z Attempt to receive a single device event from the monitor, process the event and emit corresponding signals. Called by ``QSocketNotifier``, if data is available on the udev monitoring socket. r)timeoutN)r Zpoll _emit_eventrdevicerrrr Csz(MonitorObserverMixin._process_udev_eventcCs|j|dSr) deviceEventemitrrrrrOsz MonitorObserverMixin._emit_eventN) __name__ __module__ __qualname____doc__rpropertyrsetterr rrrrrr$s   rc@s eZdZdZddZddZdS)QUDevMonitorObserverMixinz* Obsolete monitor observer mixin. cCs>t||||j|j|j|jd|_ddl}|dt dS)N)addremoveZchangemoverzAWill be removed in 1.0. Use pyudev.pyqt4.MonitorObserver instead.) rr deviceAdded deviceRemoved deviceChanged deviceMoved_action_signal_mapwarningswarnDeprecationWarning)rr rr*rrrrZsz)QUDevMonitorObserverMixin._setup_notifiercCs4|j|j||j|j}|dur0||dSr)rractionr)get)rrsignalrrrrgsz%QUDevMonitorObserverMixin._emit_eventN)rrrrrrrrrrr!Ss r!csdfdd }|S)a Generates an initializer to observer the given ``monitor`` (a :class:`~pyudev.Monitor`): ``parent`` is the parent :class:`~PyQt{4,5}.QtCore.QObject` of this object. It is passed unchanged to the inherited constructor of :class:`~PyQt{4,5}.QtCore.QObject`. Ncs||||dSr)__init__r)rr parentqobjectsocket_notifierrrr0xs zmake_init..__init__)Nr)r3r4r0rr2r make_initns r5c@seZdZdZeddZdS)MonitorObserverGenerator4 Class to generate a MonitorObserver class. cCs.ttd|tftdt||td|tiS)aGenerates an observer for device events integrating into the PyQt{4,5} mainloop. This class inherits :class:`~PyQt{4,5}.QtCore.QObject` to turn device events into Qt signals: >>> from pyudev import Context, Monitor >>> from pyudev.pyqt4 import MonitorObserver >>> context = Context() >>> monitor = Monitor.from_netlink(context) >>> monitor.filter_by(subsystem='input') >>> observer = MonitorObserver(monitor) >>> def device_event(device): ... print('event {0} on device {1}'.format(device.action, device)) >>> observer.deviceEvent.connect(device_event) >>> monitor.start() This class is a child of :class:`~{PySide, PyQt{4,5}}.QtCore.QObject`. ZMonitorObserverr0r)typestrrr5rr3r/r4rrrmake_monitor_observers   z.MonitorObserverGenerator.make_monitor_observerNrrrr staticmethodr;rrrrr6sr6c@seZdZdZeddZdS)QUDevMonitorObserverGeneratorr7cCsbttd|tftdt||td|tjttd|ttd|ttd|ttd|tiS)aGenerates an observer for device events integrating into the PyQt{4,5} mainloop. This class inherits :class:`~PyQt{4,5}.QtCore.QObject` to turn device events into Qt signals: >>> from pyudev import Context, Monitor >>> from pyudev.pyqt4 import MonitorObserver >>> context = Context() >>> monitor = Monitor.from_netlink(context) >>> monitor.filter_by(subsystem='input') >>> observer = MonitorObserver(monitor) >>> def device_event(device): ... print('event {0} on device {1}'.format(device.action, device)) >>> observer.deviceEvent.connect(device_event) >>> monitor.start() This class is a child of :class:`~{PyQt{4,5}, PySide}.QtCore.QObject`. ZQUDevMonitorObserverr0rr%r&r'r()r8r9r!r5sixZ text_typerr:rrrr;s" z3QUDevMonitorObserverGenerator.make_monitor_observerNr<rrrrr>sr>)rZ __future__rrrrr?Z pyudev.devicerobjectrr!r5r6r>rrrrs     /#