관리-도구
편집 파일: property.cpython-39.pyc
a ����װ_����������������������@���s����d�dl�mZ�d�dlmZ�d�dlmZ�d�dlmZ�d�dlm Z m Z �d�dlmZm Z �d�dlmZmZmZmZ�g�d�Zd d ��ZG�dd��de�ZG�d d��de�ZG�dd��ded�ZdS�)�����)�ABCMeta)�defaultdict��wraps)�Dict)�dbus_signal�get_xml)�DBusSpecification�DBusSpecificationError)�get_variant�Str�Variant�List)�emits_properties_changed�PropertiesException�PropertiesInterfacec��������������������s���t������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 c��������������������s"�����|�g|�R�i�|��}|������|S�)N)� flush_changes)�obj�args�kwargs�result��method���:/usr/lib/python3.9/site-packages/dasbus/server/property.py�wrapper1���s����z)emits_properties_changed.<locals>.wrapperr���)r���r���r���r���r���r���(���s���� r���c�������������������@���s���e�Zd�ZdZdS�)r���zException for DBus properties.N)�__name__� __module__�__qualname__�__doc__r���r���r���r���r���:���s���r���c�������������������@���s8���e�Zd�ZdZdd��Zdd��Zdd��Zdd ��Zd d��ZdS�) �PropertiesChangesz�Cache for properties changes. This class is useful to collect the changed properties and their values, before they are emitted on DBus. c�����������������C���s���||�_�t��|�_|��|�|�_dS�)zNCreate the cache. :param obj: an object with DBus properties N)�_object�set�_properties_names�_find_properties_specs�_properties_specs)�selfr���r���r���r����__init__F���s����zPropertiesChanges.__init__c�����������������C���sT���t��t|��}i�}|jD�]6}t|t�j�s*q|j|v�rDtd�|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&���r���Z specificationZproperties_specs�memberr���r���r���r$���O���s���� ��z(PropertiesChanges._find_properties_specsc�����������������C���sZ���|�j�}t��|�_�tt�}|D�]6}|�j|�}t|�j|�}t|j|�}|||j �|j <�q|���S�)af��Flush 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,����valueZvariantr���r���r����flushf���s���� zPropertiesChanges.flushc�����������������C���s���||�j�vrtd�|���dS�)z$Check if the property name is valid.z!DBus object has no property '{}'.N)r%���r���r+����r&���r2���r���r���r����check_property����s���� ��z PropertiesChanges.check_propertyc�����������������C���s���|���|��|�j�|��dS�)zUpdate the cache.N)r6���r#����addr5���r���r���r����update����s���� zPropertiesChanges.updateN) r���r���r���r���r'���r$���r4���r6���r8���r���r���r���r���r ���?���s��� r ���c�������������������@���sJ���e�Zd�ZdZdd��Zeeeeef�e e�d�dd��Z dd��Zd d ��ZdS�)r���a���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) c�����������������C���s���t�|��|�_dS�)zInitialize the interface.N)r ����_properties_changes)r&���r���r���r���r'�������s����zPropertiesInterface.__init__)� interface�changed�invalidc�����������������C���s���dS�)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<���r���r���r����PropertiesChanged����s���� z%PropertiesInterface.PropertiesChangedc�����������������C���s���|�j��|��dS�)z`Reports changed DBus property. :param property_name: a name of a DBus property N)r9���r8���r5���r���r���r����report_changed_property����s����z+PropertiesInterface.report_changed_propertyc�����������������C���s*���|�j����}|D�]\}}|��||g���qdS�)zFlush properties changes.N)r9���r4���r=���)r&���r1���r:���Zchangesr���r���r���r�������s���� z!PropertiesInterface.flush_changesN) r���r���r���r���r'���r���r���r���r ���r���r=���r>���r���r���r���r���r���r�������s����r���)� metaclassN)�abcr����collectionsr���� functoolsr����typingr���Zdasbus.server.interfacer���r���Zdasbus.specificationr ���r ���Z dasbus.typingr���r���r ���r����__all__r���� Exceptionr����objectr ���r���r���r���r���r����<module>���s���S