Ñò
ubSc           @   s.   d  d k  Z d „  Z d „  Z e d „ Z d S(   iÿÿÿÿNc         C   s/   t  i i i |  ƒ } t | i ƒ t | i ƒ S(   s,   Convert an XML doc into a Python dictionary.(   t   xmlt   domt   minidomt   parseStringt   removeWhitespaceNodest   documentElementt   elementToDict(   t	   xmlstringt   doc(    (    s'   /root/bin/ikeamodules/cPanel/helpers.pyt	   xmlToDict   s    c         C   sÍ   |  i  } | p d S| i t i i i i j o | i Sh  } x‡ | d j	 oy | i t i i i i	 j oP y | | i
 Wn  t j
 o g  | | i
 <n X| | i
 i t | ƒ ƒ n | i } qB W| S(   s.   Turns an XML element into a Python dictionary.N(   t
   firstChildt   Nonet   nodeTypeR    R   R   t   Nodet	   TEXT_NODEt	   nodeValuet   ELEMENT_NODEt   tagNamet   KeyErrort   appendR   t   nextSibling(   t   parentt   childt   d(    (    s'   /root/bin/ikeamodules/cPanel/helpers.pyR      s     	 c         C   s°   g  } xm |  i  D]b } | i t i i i i j o" | i i ƒ  o | i	 | ƒ q | i
 ƒ  o t | | ƒ q q Wx3 | D]+ }  |  i i |  ƒ | o |  i ƒ  q} q} Wd S(   s3   Remove leading/trailing whitespaces from XML nodes.N(   t
   childNodesR   R    R   R   R   R   t   datat   stripR   t   hasChildNodesR   t
   parentNodet   removeChildt   unlink(   t   nodeR   t   remove_listR   (    (    s'   /root/bin/ikeamodules/cPanel/helpers.pyR   *   s    
 - (   t   xml.dom.minidomR    R	   R   t   TrueR   (    (    (    s'   /root/bin/ikeamodules/cPanel/helpers.pyt   <module>   s   		