HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.60.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Nov 5 05:00:59 EST 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/lib/python3.9/site-packages/dasbus/server/__pycache__/property.cpython-39.pyc
a

װ_�@s�ddlmZddlmZddlmZddlmZddlm	Z	m
Z
ddlmZm
Z
ddlmZmZmZmZgd�Zd	d
�ZGdd�de�ZGd
d�de�ZGdd�ded�ZdS)�)�ABCMeta)�defaultdict��wraps)�Dict)�dbus_signal�get_xml)�DBusSpecification�DBusSpecificationError)�get_variant�Str�Variant�List)�emits_properties_changed�PropertiesException�PropertiesInterfacecst���fdd��}|S)a"Decorator for emitting properties changes.

    The decorated method has to be a member of a class that
    inherits PropertiesInterface.

    :param method: a DBus method of a class that inherits PropertiesInterface
    :return: a wrapper of a DBus method that emits PropertiesChanged
    cs"�|g|�Ri|��}|��|S)N)�
flush_changes)�obj�args�kwargs�result��method��:/usr/lib/python3.9/site-packages/dasbus/server/property.py�wrapper1sz)emits_properties_changed.<locals>.wrapperr)rrrrrr(s	rc@seZdZdZdS)rzException for DBus properties.N)�__name__�
__module__�__qualname__�__doc__rrrrr:src@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�PropertiesChangesz�Cache for properties changes.

    This class is useful to collect the changed properties
    and their values, before they are emitted on DBus.
    cCs||_t�|_|�|�|_dS)zNCreate the cache.

        :param obj: an object with DBus properties
        N)�_object�set�_properties_names�_find_properties_specs�_properties_specs)�selfrrrr�__init__FszPropertiesChanges.__init__cCsTt�t|��}i}|jD]6}t|tj�s*q|j|vrDtd�|j���|||j<q|S)z�Find specifications of DBus properties.

        :param obj: an object with DBus properties
        :return: a map of property names and their specifications
        z9DBus property '{}' is defined in more than one interface.)	r	Zfrom_xmlr�members�
isinstanceZProperty�namer
�format)r&rZ
specificationZproperties_specs�memberrrrr$Os

��z(PropertiesChanges._find_properties_specscCsZ|j}t�|_tt�}|D]6}|j|}t|j|�}t|j|�}|||j	|j
<q|��S)afFlush the cache.

        The content of the cache will be composed to requests
        and the cache will be cleared.

        The requests can be used to emit the PropertiesChanged
        signal. The requests are a list of tuples, that contain
        an interface name and a dictionary of properties changes.

        :return: a list of requests
        )r#r"r�dictr%�getattrr!r�typeZinterface_namer*�items)r&Zcontent�requests�
property_namer,�valueZvariantrrr�flushfs
zPropertiesChanges.flushcCs||jvrtd�|���dS)z$Check if the property name is valid.z!DBus object has no property '{}'.N)r%rr+�r&r2rrr�check_property�s
��z PropertiesChanges.check_propertycCs|�|�|j�|�dS)zUpdate the cache.N)r6r#�addr5rrr�update�s
zPropertiesChanges.updateN)	rrrrr'r$r4r6r8rrrrr ?s		r c@sJeZdZdZdd�Zeeeeefe	ed�dd��Z
dd�Zd	d
�ZdS)ra�Standard DBus interface org.freedesktop.DBus.Properties.

    DBus objects don't have to inherit this class, because the
    DBus library provides support for this interface by default.
    This class only extends this support.

    Report the changed property:

    .. code-block:: python

        self.report_changed_property('X')

    Emit all changes when the method is done:

    .. code-block:: python

        @emits_properties_changed
        def SetX(x: Int):
            self.set_x(x)

    cCst|�|_dS)zInitialize the interface.N)r �_properties_changes)r&rrrr'�szPropertiesInterface.__init__)�	interface�changed�invalidcCsdS)z�Standard signal properties changed.

        :param interface: a name of an interface
        :param changed: a dictionary of changed properties
        :param invalid: a list of invalidated properties
        :return:
        Nr)r&r:r;r<rrr�PropertiesChanged�s
z%PropertiesInterface.PropertiesChangedcCs|j�|�dS)z`Reports changed DBus property.

        :param property_name: a name of a DBus property
        N)r9r8r5rrr�report_changed_property�sz+PropertiesInterface.report_changed_propertycCs*|j��}|D]\}}|�||g�qdS)zFlush properties changes.N)r9r4r=)r&r1r:Zchangesrrrr�s
z!PropertiesInterface.flush_changesN)
rrrrr'rrrr
rr=r>rrrrrr�s�r)�	metaclassN)�abcr�collectionsr�	functoolsr�typingrZdasbus.server.interfacerrZdasbus.specificationr	r
Z
dasbus.typingrrr
r�__all__r�	Exceptionr�objectr rrrrr�<module>sS