Ë
    Ï"Kb>  ã            
       ó
  — d dl Z d dlZd dlZd dlZ	 e dd„Zdd„Z	 	 dd„Z	dddd	d
dddœZ
 e j                  ddj                   ee j                  e
j                  «       «      «      z  «      Zdd„Zy# e$ r	 d dlmZ Y Œmw xY w)é    N)Úreducec                 óp   — d|z  g}|r|j                  d«       t        || |«       dj                  |«      S )ay   Writes the XML content to disk, touching the file only if it has changed.

  Visual Studio files have a lot of pre-defined structures.  This function makes
  it easy to represent these structures as Python data structures, instead of
  having to create a lot of function calls.

  Each XML element of the content is represented as a list composed of:
  1. The name of the element, a string,
  2. The attributes of the element, a dictionary (optional), and
  3+. The content of the element, if any.  Strings are simple text nodes and
      lists are child elements.

  Example 1:
      <test/>
  becomes
      ['test']

  Example 2:
      <myelement a='value1' b='value2'>
         <childtype>This is</childtype>
         <childtype>it!</childtype>
      </myelement>

  becomes
      ['myelement', {'a':'value1', 'b':'value2'},
         ['childtype', 'This is'],
         ['childtype', 'it!'],
      ]

  Args:
    content:  The structured content to be converted.
    encoding: The encoding to report on the first XML line.
    pretty: True if we want pretty printing with indents and new lines.

  Returns:
    The XML content as a string.
  z#<?xml version="1.0" encoding="%s"?>ú
Ú )ÚappendÚ_ConstructContentListÚjoin)ÚcontentÚencodingÚprettyÚ	xml_partss       ú./usr/lib/python3/dist-packages/gyp/easy_xml.pyÚXmlToStringr      s@   € ðN 5°xÑ?Ð@€)ÙØ×Ñ�TÔÜ˜	 7¨FÔ3ð 
�‰�Ó	Ðó    c           
      óì  — |rd|z  }d}nd}d}|d   }t        |t        «      st        dt        |«      z   «      ‚| j                  |dz   |z   «       |dd }|r_t        |d   t        «      rLt        |d   j                  «       «      D ](  \  }}	| j                  d	|›d
t        |	d¬«      ›d�«       Œ* |dd }|r§| j                  d«       t        d„ |d«      }
|
 }|r|r| j                  |«       |D ]>  }t        |t        «      r| j                  t        |«      «       Œ.t        | |||dz   «       Œ@ |r|r| j                  |«       | j                  d|›d|›�«       y| j                  d|z  «       y)a+   Appends the XML parts corresponding to the specification.

  Args:
    xml_parts: A list of XML parts to be appended to.
    specification:  The specification of the element.  See EasyXml docs.
    pretty: True if we want pretty printing with indents and new lines.
    level: Indentation level.
  z  r   r   r   zRThe first item of an EasyXml specification should be a string.  Specification was ú<é   Nú z="T)Úattrú"ú>c                 ó*   — | xr t        |t        «      S )N)Ú
isinstanceÚstr)ÚxÚys     r   ú<lambda>z'_ConstructContentList.<locals>.<lambda>^   s   €  aÒ&>¬J°q¼#Ó,>€ r   z</z/>%s)
r   r   Ú	Exceptionr   ÚdictÚsortedÚitemsÚ
_XmlEscaper   r   )r   Úspecificationr   ÚlevelÚindentationÚnew_lineÚnameÚrestÚatÚvalÚall_stringsÚ
multi_lineÚ
child_specs                r   r   r   @   s‹  € ñ Ø˜‘,€KØ�Hà€KØ€HØ	�qÑ	€$Ü	�Dœ#Ô	Ü
ð 4Ü69¸-Ó6HñIó Jð Jà×Ñ�; Ñ$ tÑ+Ô,ð 
�q�rÐ	€$Ù	Œj˜˜a™¤$Ô'Ü˜$˜q™'Ÿ-™-›/Ó*ò F‰ˆˆCØ×Ò¢R¬°C¸dÖ)CÐDÕEðFà��ˆ8€DÙ	Ø×Ñ�SÔÜÑ>ÀÀdÓK€KØ �€JÙ‘hØ×Ñ�xÔ Øò Hˆ
ô 
�J¤Ô	$Ø×Ñœ
 :Ó.Õ/ä˜i¨°V¸UÀQ¹YÕGðHñ ‘kØ×Ñ�{Ô#Ø×Ò¢$©Ð1Õ2à×Ñ�V˜hÑ&Õ'r   c                 ó  — t        | ||«      }|r€t        j                  dk7  rm|j                  dd«      }t	        j
                  «       d   }|rB|j                  «       |j                  «       k7  r!	 |j                  |«      j                  |«      }	 t        |d«      }|j                  «       }|j                  «        ||k7  r.t        |d«      }|j                  |«       |j                  «        yy# t        $ r Y Œlw xY w#  d}Y ŒIxY w)a:   Writes the XML content to disk, touching the file only if it has changed.

  Args:
    content:  The structured content to be written.
    path: Location of the file.
    encoding: The encoding to report on the first line of the XML file.
    pretty: True if we want pretty printing with indents and new lines.
  z
r   r   ÚrNÚw)r   ÚosÚlinesepÚreplaceÚlocaleÚgetdefaultlocaleÚupperÚdecodeÚencodeÚAttributeErrorÚopenÚreadÚcloseÚwrite)	r
   Úpathr   r   Úwin32Ú
xml_stringÚdefault_encodingÚfÚexistings	            r   ÚWriteXmlIfChangedrD   p   sô   € ô ˜7 H¨fÓ5€*Ù
Œr�z‰z˜VÒ#Ø×#Ñ# D¨&Ó1€JÜ×.Ñ.Ó0°Ñ3ÐÙÐ,×2Ñ2Ó4¸¿¹Ó8HÒHðØ×&Ñ&Ð'7Ó8×?Ñ?ÀÓIˆ
ð
ÜˆT�3‹€AØ�v‰v‹x€HØ‡G�G„Ið
 �ÒÜˆT�3‹€AØ‡G�GˆJÔØ‡G�G…Ið øô ò ÙðûðØ‚Hús   Á0 C1 Â,D  Ã1	C=Ã<C=Ä Dz&quot;z&apos;z&lt;z&gt;z&amp;z&#xA;z&#xD;)r   ú'r   r   ú&r   úz(%s)ú|c                 ó:   ‡— ˆfd„}t         j                  || «      S )z& Escape a string for inclusion in XML.c                 ó~   •— | j                   | j                  «       | j                  «        }‰r|dk(  r|S t        |   S )NrE   )ÚstringÚstartÚendÚ_xml_escape_map)ÚmatchÚmr   s     €r   r3   z_XmlEscape.<locals>.replace¤   s8   ø€ Ø�‰�U—[‘[“] U§Y¡Y£[Ð1€Aá��S’Ø€hÜ˜1ÑÐr   )Ú_xml_escape_reÚsub)Úvaluer   r3   s    ` r   r"   r"   ¢   s   ø€ ôô 
×	Ñ	˜G UÓ	+Ð+r   )úutf-8F)r   )rT   FF)F)Úrer1   r4   Úsysr   Ú	NameErrorÚ	functoolsr   r   rD   rN   Úcompiler	   ÚmapÚescapeÚkeysrQ   r"   © r   r   ú<module>r^      s¥   ðó
 
Û 	Û Û 
ðáó-ó`-(ð` ?DØ!ó ðH 
Ø	Ø	Ø	Ø	Ø
Ø
ñ€ð �—‘Ø
ˆS�X‰X‘c˜"Ÿ)™) _×%9Ñ%9Ó%;Ó<Ó=Ñ=ó?€ô,øðk ò ßðús   ’A4 Á4BÂB