grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026a ÊicÃ#ã@sTddlmZddlmZgd¢ZGdd„deƒZGdd„deƒZGdd „d eƒZ d S) é)Ú namedtuple)Ú XMLParser)ÚDBusSpecificationErrorÚDBusSpecificationÚDBusSpecificationParserc@seZdZdZdS)rz,Exception for the DBus specification errors.N)Ú__name__Ú __module__Ú __qualname__Ú__doc__©r r ú8/usr/lib/python3.9/site-packages/dasbus/specification.pyr#src@s˜eZdZdZdZdZdZdZdZdZ dZ e d gd ¢ƒZ e d gd ¢ƒZ e d gd¢ƒZdgZedd„ƒZdd„Zedd„ƒZedd„ƒZdd„Zdd„ZdS)rzDBus XML specification.ÚinÚoutÚreadÚwriteZ readwriteÚreturnaÙ ÚSignal©ÚnameÚinterface_nameÚtypeÚMethod©rrZin_typeZout_typeÚProperty©rrÚreadableÚwritablerÚ_memberscCs t ||¡S)z.Return a DBus specification for the given XML.)rÚparse_specification)ÚclsÚxmlr r r Úfrom_xmlpszDBusSpecification.from_xmlcCs i|_dS)z Create a new DBus specification.N)r©Úselfr r r Ú__init__uszDBusSpecification.__init__cCstt|j ¡ƒ ¡ƒS)z%Interfaces of the DBus specification.)ÚlistÚdictrÚkeysr"r r r Ú interfacesyszDBusSpecification.interfacescCst|j ¡ƒS)z"Members of the DBus specification.)r%rÚvaluesr"r r r Úmembers~szDBusSpecification.memberscCs||j|j|jf<dS)z!Add a member of a DBus interface.N)rrr)r#Úmemberr r r Ú add_memberƒszDBusSpecification.add_membercCs8z|j||fWSty"Yn0td ||¡ƒ‚dS)z!Get a member of a DBus interface.z)DBus specification has no member '{}.{}'.N)rÚKeyErrorrÚformat)r#rÚ member_namer r r Ú get_member‡s ÿÿzDBusSpecification.get_memberN)rrr r Ú DIRECTION_INÚ DIRECTION_OUTÚ ACCESS_READÚ ACCESS_WRITEÚACCESS_READWRITEZRETURN_PARAMETERÚSTANDARD_INTERFACESrrrrÚ __slots__Ú classmethodr!r$Úpropertyr(r*r,r0r r r r r(s*&    rc@sleZdZdZeZeefdd„ƒZedd„ƒZ edd„ƒZ edd „ƒZ ed d „ƒZ ed d „ƒZ edd„ƒZdS)rz)Class for parsing DBus XML specification.cCs$|ƒ}| |tj¡| ||¡|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_xmlrr6)rr ÚfactoryÚ specificationr r r r›s z+DBusSpecificationParser.parse_specificationcCs4|j |¡}|D]}|j |¡s"q| ||¡qdS)zParse the given XML.N)Ú xml_parserZxml_to_elementZ is_interfaceÚ_parse_interface)rr<r ZnodeÚinterface_elementr r r r:¨s   z"DBusSpecificationParser._parse_xmlcCst|j |¡}|D]^}|j |¡r.| ||¡}n6|j |¡rH| ||¡}n|j |¡r| ||¡}nq| |¡q|S)z8Parse the interface element from the DBus specification.) r=Úget_nameZ is_propertyÚ_parse_propertyZ is_signalÚ _parse_signalZ is_methodÚ _parse_methodr,)rr<r?rZmember_elementr+r r r r>µs     z(DBusSpecificationParser._parse_interfacecCsX|j |¡}|j |¡}|j |¡}|tjtjfv}|tjtjfv}tj|||||d�S)z7Parse the property element from the DBus specification.r) r=r@Úget_typeZ get_accessrr3r5r4r)rrZproperty_elementZ property_nameZ property_typeZproperty_accessrrr r r rAÎs$   þþûz'DBusSpecificationParser._parse_propertycCsT|j |¡}g}|D](}|j |¡s&q|j |¡}| |¡qtj||| |¡d�S)z5Parse the signal element from the DBus specification.r)r=r@Ú is_parameterrDÚappendrrÚ _get_type)rrZsignal_elementZ signal_nameZ signal_typeÚelementÚ element_typer r r rBçs    ýz%DBusSpecificationParser._parse_signalc CsŒ|j |¡}g}g}|D]T}|j |¡s*q|j |¡}|j |¡}|tjkrX| |¡q|tjkr| |¡qtj |||  |¡|  |¡d�S)z5Parse the method element from the DBus specification.r) r=r@rEZ get_directionrDrr1rFr2rrG) rrZmethod_elementZ method_nameZin_typesZ out_typesrHÚ directionrIr r r rCús$        üz%DBusSpecificationParser._parse_methodcCs|sdSd d |¡¡S)zJoin types into one value.Nz({})Ú)r.Újoin)rÚtypesr r r rGsz!DBusSpecificationParser._get_typeN)rrr r rr=r8rrr:r>rArBrCrGr r r r r•s       rN) Ú collectionsrZ dasbus.xmlrÚ__all__Ú ExceptionrÚobjectrrr r r r Ús  m