Mini Shell

Direktori : /usr/lib/python3.6/site-packages/dasbus/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/dasbus/__pycache__/specification.cpython-36.opt-1.pyc

3

��^�#�@sVddlmZddlmZdddgZGdd�de�ZGdd�de�ZGdd�de�Z	d	S)
�)�
namedtuple)�	XMLParser�DBusSpecificationError�DBusSpecification�DBusSpecificationParserc@seZdZdZdS)rz,Exception for the DBus specification errors.N)�__name__�
__module__�__qualname__�__doc__�rr�#/usr/lib/python3.6/specification.pyr#sc@s�eZdZdZdZdZdZdZdZdZ	dZ
ed	d
ddg�Zed
d
dddg�Z
edd
ddddg�ZdgZedd��Zdd�Zedd��Zedd��Zdd�Zdd�Zd S)!rzDBus XML specification.�in�out�read�writeZ	readwrite�returna�
    <node>
        <interface name="org.freedesktop.DBus.Introspectable">
            <method name="Introspect">
            <arg type="s" name="xml_data" direction="out"/>
            </method>
        </interface>
        <interface name="org.freedesktop.DBus.Peer">
            <method name="Ping"/>
            <method name="GetMachineId">
                <arg type="s" name="machine_uuid" direction="out"/>
            </method>
       </interface>
        <interface name="org.freedesktop.DBus.Properties">
            <method name="Get">
                <arg type="s" name="interface_name" direction="in"/>
                <arg type="s" name="property_name" direction="in"/>
                <arg type="v" name="value" direction="out"/>
            </method>
            <method name="GetAll">
                <arg type="s" name="interface_name" direction="in"/>
                <arg type="a{sv}" name="properties" direction="out"/>
            </method>
            <method name="Set">
                <arg type="s" name="interface_name" direction="in"/>
                <arg type="s" name="property_name" direction="in"/>
                <arg type="v" name="value" direction="in"/>
            </method>
            <signal name="PropertiesChanged">
                <arg type="s" name="interface_name"/>
                <arg type="a{sv}" name="changed_properties"/>
                <arg type="as" name="invalidated_properties"/>
            </signal>
        </interface>
    </node>
    �Signal�name�interface_name�type�Method�in_type�out_type�Property�readable�writable�_memberscCstj||�S)z.Return a DBus specification for the given XML.)r�parse_specification)�cls�xmlrrr�from_xmlpszDBusSpecification.from_xmlcCs
i|_dS)z Create a new DBus specification.N)r)�selfrrr�__init__uszDBusSpecification.__init__cCstt|jj��j��S)z%Interfaces of the DBus specification.)�list�dictr�keys)r!rrr�
interfacesyszDBusSpecification.interfacescCst|jj��S)z"Members of the DBus specification.)r#r�values)r!rrr�members~szDBusSpecification.memberscCs||j|j|jf<dS)z!Add a member of a DBus interface.N)rrr)r!�memberrrr�
add_member�szDBusSpecification.add_membercCs8y|j||fStk
r"YnXtdj||���dS)z!Get a member of a DBus interface.z)DBus specification has no member '{}.{}'.N)r�KeyErrorr�format)r!r�member_namerrr�
get_member�szDBusSpecification.get_memberN)rrr	r
�DIRECTION_IN�
DIRECTION_OUT�ACCESS_READ�ACCESS_WRITE�ACCESS_READWRITEZRETURN_PARAMETER�STANDARD_INTERFACESrrrr�	__slots__�classmethodr r"�propertyr&r(r*r.rrrrr(s<%c@sleZdZdZeZeefdd��Zedd��Z	edd��Z
edd	��Zed
d��Zedd
��Z
edd��ZdS)rz)Class for parsing DBus XML specification.cCs$|�}|j|tj�|j||�|S)z�Generate a representation of a DBus XML specification.

        :param xml: the XML specification to parse
        :param factory: the DBus specification factory
        :return: a representation od the DBus specification
        )�
_parse_xmlrr4)rr�factory�
specificationrrrr�sz+DBusSpecificationParser.parse_specificationcCs8|jj|�}x&|D]}|jj|�s$q|j||�qWdS)zParse the given XML.N)�
xml_parserZxml_to_elementZis_interface�_parse_interface)rr:rZnode�interface_elementrrrr8�s

z"DBusSpecificationParser._parse_xmlcCsx|jj|�}xf|D]^}|jj|�r0|j||�}n6|jj|�rJ|j||�}n|jj|�r|j||�}nq|j|�qW|S)z8Parse the interface element from the DBus specification.)	r;�get_nameZis_property�_parse_propertyZ	is_signal�
_parse_signalZ	is_method�
_parse_methodr*)rr:r=rZmember_elementr)rrrr<�s
z(DBusSpecificationParser._parse_interfacecCsX|jj|�}|jj|�}|jj|�}|tjtjfk}|tjtjfk}tj|||||d�S)z7Parse the property element from the DBus specification.)rrrrr)	r;r>�get_typeZ
get_accessrr1r3r2r)rrZproperty_elementZ
property_nameZ
property_typeZproperty_accessrrrrrr?�s

z'DBusSpecificationParser._parse_propertycCsX|jj|�}g}x0|D](}|jj|�s(q|jj|�}|j|�qWtj|||j|�d�S)z5Parse the signal element from the DBus specification.)rrr)r;r>�is_parameterrB�appendrr�	_get_type)rrZsignal_elementZsignal_nameZsignal_type�element�element_typerrrr@�s
z%DBusSpecificationParser._parse_signalc	Cs�|jj|�}g}g}x\|D]T}|jj|�s,q|jj|�}|jj|�}|tjkrZ|j|�q|tjkr|j|�qWtj	|||j
|�|j
|�d�S)z5Parse the method element from the DBus specification.)rrrr)r;r>rCZ
get_directionrBrr/rDr0rrE)	rrZmethod_elementZmethod_nameZin_typesZ	out_typesrF�	directionrGrrrrA�s"


z%DBusSpecificationParser._parse_methodcCs|sdSdjdj|��S)zJoin types into one value.Nz({})�)r,�join)r�typesrrrrEsz!DBusSpecificationParser._get_typeN)rrr	r
rr;r6rrr8r<r?r@rArErrrrr�s
N)
�collectionsrZ
dasbus.xmlr�__all__�	Exceptionr�objectrrrrrr�<module>sm