3 ˆuAcØã@sÚdZddlmZddlmZddlmZddlmZGdd„de ƒZ Gdd „d ee e ƒƒZ Gd d „d e ƒZ Gd d „d e ƒZGdd„de eƒZGdd„de ƒZGdd„de ƒZGdd„de ƒZGdd„de eƒZdd„ZdS)z?Classes and functions to easily access DBus introspection data.é)Úabsolute_import)Ú ElementTree)ÚStringIO)Úwith_metaclassc@s(eZdZdZiZedd„ƒZdd„ZdS)Ú IElemMetaz©Metaclass for introspection elements. Sets elemname class member automatically from class name if not set explicitly. Registers classes for their element names.cCs>d}x4|D],}|jƒ}||kr.t|ƒr.|d7}||7}q W|S)NÚÚ_)ÚlowerÚlen)ÚclsZclsnameÚelemnameÚcZc_lower©rú#/usr/lib/python3.6/introspection.pyÚclsname_to_elemname(s  zIElemMeta.clsname_to_elemnamecCsŒ|dkrtj||||ƒSd|krL|jdƒs6td|ƒ‚tj|dd…ƒ|d<|d}|tjkrntd||fƒ‚tj||||ƒ}|tj|<|S)NÚIElemr z;Class '%s' needs to set elemname (or be called 'IElem...'))éz4Class '%s' tries to register duplicate elemname '%s')ÚtypeÚ__new__Ú startswithÚ TypeErrorrrÚelemnames_to_classes)r ÚnameÚbasesZdctr Úklsrrrr3s     zIElemMeta.__new__N)Ú__name__Ú __module__Ú __qualname__Ú__doc__rÚ classmethodrrrrrrr s rcs@eZdZdZd ‡fdd„ Zd dd„Zdd„Zed d „ƒZ‡Z S) rz&Base class for introspection elements.Ncs*tjj|jtjdƒ}tt|ƒj|||ƒS)N)rrÚgetÚtagÚsuperrr)r ÚelemÚparentr)Ú __class__rrrOsz IElem.__new__cs$|ˆ_|ˆ_‡fdd„|Dƒˆ_dS)Ncsg|]}t|ˆd‘qS))r$)r)Ú.0r )Úselfrrú Wsz"IElem.__init__..)r#r$Úchild_elements)r'r#r$r)r'rÚ__init__TszIElem.__init__cCsZd|jr|jn d|jj|jf}x2|jD](}x"t|ƒjdƒD]}|d|7}q>Wq*W|S)Nz%s %rz unknown:%sÚ z %s)r r#r!Úattribr)ÚstrÚsplit)r'Úsr ZccrrrÚ__str__Ys  z IElem.__str__cCs|jjS)N)r#r,)r'rrrr,asz IElem.attrib)N)N) rrrrrr*r0Úpropertyr,Ú __classcell__rr)r%rrLs  rc@seZdZdZdZdS)Ú IElemUnknownz-Catch-all for unknown introspection elements.N)rrrrr rrrrr3fsr3c@seZdZdZedd„ƒZdS)ÚIElemNameMixinz,Mixin for introspection elements with names.cCs |jdS)Nr)r,)r'rrrroszIElemNameMixin.nameN)rrrrr1rrrrrr4lsr4cs"eZdZdZd‡fdd„ Z‡ZS)Ú IElemNodezIntrospection node.Ncs(tt|ƒj||ƒdd„|jDƒ|_dS)NcSsg|]}t|tƒr|‘qSr)Ú isinstancer5)r&r rrrr({sz&IElemNode.__init__..)r"r5r*r)Z child_nodes)r'r#r$)r%rrr*wszIElemNode.__init__)N)rrrrr*r2rr)r%rr5tsr5c@seZdZdZdS)ÚIElemInterfacezIntrospection interface.N)rrrrrrrrr7~sr7c@seZdZdZdS)Ú IElemMethodzIntrospection interface method.N)rrrrrrrrr8‚sr8c@seZdZdZdS)ÚIElemArgzIntrospection method argument.N)rrrrrrrrr9†sr9c@seZdZdZdS)Ú IElemSignalzIntrospection interface signal.N)rrrrrrrrr:Šsr:cCs.tƒ}t|dƒst|ƒ}|j|ƒ}t|ƒ}|S)NÚread)rÚhasattrrÚparser)Zstring_or_fileZtreeZxml_rootZ elem_rootrrrÚ introspectŽs   r>N)rZ __future__rZxml.etree.ElementTreerÚiorZsixrrrÚobjectrr3r4r5r7r8r9r:r>rrrrÚs    ,