ó
ŸÃ9Qc           @   sÿ   d  Z  d d l m Z d d l m Z d e f d     YZ d e f d     YZ d e f d	     YZ d
 e f d     YZ	 d e e	 f d     YZ
 d e f d     YZ d e f d     YZ d e f d     YZ d e e	 f d     YZ d   Z d S(   s?   Classes and functions to easily access DBus introspection data.iÿÿÿÿ(   t   ElementTree(   t   StringIOt	   IElemMetac           B   s,   e  Z d  Z i  Z e d    Z d   Z RS(   s©   Metaclass for introspection elements.

    Sets elemname class member automatically from class name if not set
    explicitly. Registers classes for their element names.c         C   sY   d } xL | D]D } | j    } | | k rG t |  rG | d 7} qG n  | | 7} q W| S(   Nt    t   _(   t   lowert   len(   t   clst   clsnamet   elemnamet   ct   c_lower(    (    s;   /usr/lib/python2.7/site-packages/slip/dbus/introspection.pyt   clsname_to_elemname   s    c         C   sÅ   | d k r" t  j |  | | |  Sd | k rj | j d  sP t d |   n  t j | d  | d <n  | d } | t j k r t d | | f   n  t  j |  | | |  } | t j | <| S(   Nt   IElemR	   s;   Class '%s' needs to set elemname (or be called 'IElem...'))i   s4   Class '%s' tries to register duplicate elemname '%s'(   t   typet   __new__t
   startswitht	   TypeErrorR   R   t   elemnames_to_classes(   R   t   namet   basest   dctR	   t   kls(    (    s;   /usr/lib/python2.7/site-packages/slip/dbus/introspection.pyR      s    
(   t   __name__t
   __module__t   __doc__R   t   classmethodR   R   (    (    (    s;   /usr/lib/python2.7/site-packages/slip/dbus/introspection.pyR   	   s   R   c           B   sD   e  Z d  Z e Z d d  Z d d  Z d   Z e	 d    Z
 RS(   s&   Base class for introspection elements.c         C   s;   t  j j | j t  j d   } t t |   j | | |  S(   N(   R   R   t   gett   tagt   Nonet   superR   R   (   R   t   elemt   parentR   (    (    s;   /usr/lib/python2.7/site-packages/slip/dbus/introspection.pyR   8   s    c         C   s>   | |  _  | |  _ g  | D] } t | d |  ^ q |  _ d  S(   NR    (   R   R    R   t   child_elements(   t   selfR   R    R
   (    (    s;   /usr/lib/python2.7/site-packages/slip/dbus/introspection.pyt   __init__=   s    		c         C   su   d |  j  r |  j  n d |  j j |  j f } x? |  j D]4 } x+ t |  j d  D] } | d | 7} qU Wq9 W| S(   Ns   %s %rs
   unknown:%ss   
s   
  %s(   R	   R   R   t   attribR!   t   strt   split(   R"   t   sR
   t   cc(    (    s;   /usr/lib/python2.7/site-packages/slip/dbus/introspection.pyt   __str__B   s    c         C   s
   |  j  j S(   N(   R   R$   (   R"   (    (    s;   /usr/lib/python2.7/site-packages/slip/dbus/introspection.pyR$   J   s    N(   R   R   R   R   t   __metaclass__R   R   R#   R)   t   propertyR$   (    (    (    s;   /usr/lib/python2.7/site-packages/slip/dbus/introspection.pyR   3   s   	t   IElemUnknownc           B   s   e  Z d  Z d Z RS(   s-   Catch-all for unknown introspection elements.N(   R   R   R   R   R	   (    (    (    s;   /usr/lib/python2.7/site-packages/slip/dbus/introspection.pyR,   O   s   t   IElemNameMixinc           B   s   e  Z d  Z e d    Z RS(   s,   Mixin for introspection elements with names.c         C   s   |  j  d S(   NR   (   R$   (   R"   (    (    s;   /usr/lib/python2.7/site-packages/slip/dbus/introspection.pyR   X   s    (   R   R   R   R+   R   (    (    (    s;   /usr/lib/python2.7/site-packages/slip/dbus/introspection.pyR-   U   s   t	   IElemNodec           B   s   e  Z d  Z d d  Z RS(   s   Introspection node.c         C   sK   t  t |   j | |  g  |  j D] } t | t  r# | ^ q# |  _ d  S(   N(   R   R.   R#   R!   t
   isinstancet   child_nodes(   R"   R   R    R
   (    (    s;   /usr/lib/python2.7/site-packages/slip/dbus/introspection.pyR#   `   s    N(   R   R   R   R   R#   (    (    (    s;   /usr/lib/python2.7/site-packages/slip/dbus/introspection.pyR.   ]   s   t   IElemInterfacec           B   s   e  Z d  Z RS(   s   Introspection interface.(   R   R   R   (    (    (    s;   /usr/lib/python2.7/site-packages/slip/dbus/introspection.pyR1   f   s   t   IElemMethodc           B   s   e  Z d  Z RS(   s   Introspection interface method.(   R   R   R   (    (    (    s;   /usr/lib/python2.7/site-packages/slip/dbus/introspection.pyR2   j   s   t   IElemArgc           B   s   e  Z d  Z RS(   s   Introspection method argument.(   R   R   R   (    (    (    s;   /usr/lib/python2.7/site-packages/slip/dbus/introspection.pyR3   n   s   t   IElemSignalc           B   s   e  Z d  Z RS(   s   Introspection interface signal.(   R   R   R   (    (    (    s;   /usr/lib/python2.7/site-packages/slip/dbus/introspection.pyR4   r   s   c         C   sF   t    } t |  d  s' t |   }  n  | j |   } t |  } | S(   Nt   read(   R    t   hasattrR   t   parseR   (   t   string_or_filet   treet   xml_roott	   elem_root(    (    s;   /usr/lib/python2.7/site-packages/slip/dbus/introspection.pyt
   introspectv   s    	N(   R   t   xml.etree.ElementTreeR    R   R   R   t   objectR   R,   R-   R.   R1   R2   R3   R4   R<   (    (    (    s;   /usr/lib/python2.7/site-packages/slip/dbus/introspection.pyt   <module>   s   *	