ó
ÓnäZc           @   sJ   d  Z  d d l Z e d „ Z d d d d „ Z d e f d „  ƒ  YZ d S(   sî   Applies a fix to CR LF TAB handling in xml.dom.

Fixes this: http://code.google.com/p/chromium/issues/detail?id=76293
Working around this: http://bugs.python.org/issue5752
TODO(bradnelson): Consider dropping this when we drop XP support.
iÿÿÿÿNc         C   s€   | j  d d ƒ j  d d ƒ } | j  d d ƒ j  d d ƒ } | ro | j  d	 d
 ƒ j  d d ƒ j  d d ƒ } n  |  j | ƒ d S(   s   Writes datachars to writer.t   &s   &amp;t   <s   &lt;s   "s   &quot;t   >s   &gt;s   s   &#xD;s   
s   &#xA;s   	s   &#x9;N(   t   replacet   write(   t   writert   datat	   is_attrib(    (    s/   /usr/lib/python2.7/dist-packages/gyp/xml_fix.pyt   _Replacement_write_data   s    t    c   	      C   s   | j  | d |  j ƒ |  j ƒ  } | j ƒ  } | j ƒ  xF | D]> } | j  d | ƒ t | | | j d t ƒ| j  d ƒ qA W|  j rë | j  d | ƒ x+ |  j D]  } | j	 | | | | | ƒ q§ W| j  d | |  j | f ƒ n | j  d | ƒ d  S(   NR   s    %s="R   s   "s   >%ss	   %s</%s>%ss   />%s(
   R   t   tagNamet   _get_attributest   keyst   sortR   t   valuet   Truet
   childNodest   writexml(	   t   selfR   t   indentt	   addindentt   newlt   attrst   a_namest   a_namet   node(    (    s/   /usr/lib/python2.7/dist-packages/gyp/xml_fix.pyt   _Replacement_writexml   s    
	 t   XmlFixc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s7   Object to manage temporary patching of xml.dom.minidom.c         C   sL   t  j j j |  _ t  j j j j |  _ t t  j j _ t t  j j j _ d  S(   N(	   t   xmlt   domt   minidomt   _write_datat
   write_datat   ElementR   R   R   (   R   (    (    s/   /usr/lib/python2.7/dist-packages/gyp/xml_fix.pyt   __init__6   s    c         C   s@   |  j  r< |  j  t j j _ |  j t j j j _ d  |  _  n  d  S(   N(   R    R   R   R   R   R   R!   t   None(   R   (    (    s/   /usr/lib/python2.7/dist-packages/gyp/xml_fix.pyt   Cleanup>   s    	c         C   s   |  j  ƒ  d  S(   N(   R$   (   R   (    (    s/   /usr/lib/python2.7/dist-packages/gyp/xml_fix.pyt   __del__D   s    (   t   __name__t
   __module__t   __doc__R"   R$   R%   (    (    (    s/   /usr/lib/python2.7/dist-packages/gyp/xml_fix.pyR   3   s   		(   R(   t   xml.dom.minidomR   t   FalseR   R   t   objectR   (    (    (    s/   /usr/lib/python2.7/dist-packages/gyp/xml_fix.pyt   <module>
   s   