ó
    æ“–g1  ã            
       ó  • S SK r S SKrS SKrS SKrS SKJr  SS jrSS jrSS\ R                  S:H  4S jr	S	S
SSSSSS.r
\R                  " SSR                  \" \R                  \
R                  5       5      5      -  5      rSS jrg)é    N)Úreduceúutf-8Fc                 óx   • SU-  /nU(       a  UR                  S5        [        X0U5        SR                  U5      $ )a>  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 7¸ÑAÐB€IÞØ×Ñ˜ÔÜ˜)¨fÔ5ð �7‰7�9ÓÐó    c                 óV  • U(       a  SU-  nSnOSnSnUS   n[        U[        5      (       d  [        S[        U5      -   5      eU R                  US-   U-   5        USS nU(       ab  [        US   [        5      (       aJ  [        US   R                  5       5       H%  u  p‰U R                  S	U S
[        U	SS9 S35        M'     USS nU(       aÅ  U R                  S5        [        S US5      n
U
(       + nU(       a  U(       a  U R                  U5        U HC  n[        U[        5      (       a  U R                  [        U5      5        M4  [        XX#S-   5        ME     U(       a  U(       a  U R                  U5        U R                  SU SU 35        gU R                  SU-  5        g)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                 ó4   • U =(       a    [        U[        5      $ )N)Ú
isinstanceÚstr)ÚxÚys     r   Ú<lambda>Ú'_ConstructContentList.<locals>.<lambda>\   s   € ¨!×*B´
¸1¼cÓ0BÐ*Br   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“  € ö Ø˜U‘lˆØ‰àˆØˆØ˜Ñ€DÜ�dœC× Ñ Üð,Ü.1°-Ó.@ñAó
ð 	
ð ×Ñ�[ 3Ñ&¨Ñ-Ô.ð ˜˜Ð€DÞ”
˜4 ™7¤D×)Ñ)Ü˜d 1™gŸm™m›oÖ.‰GˆBØ×Ñ˜q   B¤z°#¸DÑ'AÐ&BÀ!ÐDÖEñ /à�A�BˆxˆÞØ×Ñ˜ÔÜÑBÀDÈ$ÓOˆØ$”_ˆ
Þž(Ø×Ñ˜XÔ&ÛˆJô ˜*¤c×*Ñ*Ø× Ñ ¤¨JÓ!7Ö8ä% i¸VÈQÁYÖOñ ö ž+Ø×Ñ˜[Ô)Ø×Ñ˜2˜d˜V 1 X JÐ/Õ0à×Ñ˜ (Ñ*Õ+r   Úwin32c                 ór  • [        XU5      nU(       a&  [        R                  S:w  a  UR                  SS5      n [        R
                  " 5       S   nU(       a3  UR                  5       UR                  5       :w  a  UR                  U5      n [        U5       nUR                  5       nSSS5        WU:w  a'  [        US5       nUR                  U5        SSS5        gg! [         a    [        R                  " 5       n N®f = f! , (       d  f       Na= f! [         a    Sn Nrf = f! , (       d  f       g= f)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   NÚwb)r   ÚosÚlinesepÚreplaceÚlocaleÚgetdefaultlocaleÚAttributeErrorÚgetencodingÚupperÚencodeÚopenÚreadÚOSErrorÚwrite)	r   Úpathr   r   r0   Ú
xml_stringÚdefault_encodingÚfileÚexistings	            r   ÚWriteXmlIfChangedrE   n   s  € ô ˜W°Ó7€JÞ”—‘˜vÓ%Ø×'Ñ'¨¨fÓ5ˆ
ð0Ü!×2Ò2Ó4°QÑ7Ðö Ð,×2Ñ2Ó4¸¿¹Ó8HÓHØ×&Ñ& xÓ0ˆ
ðÜ�$ŒZ˜4Ø—y‘y“{ˆH÷ ð �:ÓÜ�$˜Ô Ø�J‰J�zÔ"÷ Ðð øô ó 0Ü!×-Ò-Ó/Òð0ú÷ �Zûäó ØŠðú÷
 ÕúsM   »C  ÂD ÂDÂ*D ÃD(Ã DÄDÄ
DÄD ÄD ÄD%Ä$D%Ä(
D6z&quot;z&apos;z&lt;z&gt;z&amp;z&#xA;z&#xD;)r   Ú'r   r   Ú&r   Úz(%s)Ú|c                 ó:   ^• U4S jn[         R                  X 5      $ )z%Escape a string for inclusion in XML.c                 óŠ   >• U R                   U R                  5       U R                  5        nT(       a  US:X  a  U$ [        U   $ )NrF   )ÚstringÚstartÚendÚ_xml_escape_map)ÚmatchÚmr   s     €r   r5   Ú_XmlEscape.<locals>.replace¢   s8   ø€ Ø�L‰L˜Ÿ™›¨¯©«Ð5ˆæ�A˜“HØˆHÜ˜qÑ!Ð!r   )Ú_xml_escape_reÚsub)Úvaluer   r5   s    ` r   r$   r$   Ÿ   s   ø€ õ"ô ×Ñ˜gÓ-Ð-r   )r   F)r   )F)ÚsysÚrer3   r6   Ú	functoolsr   r   r	   ÚplatformrE   rO   Úcompiler
   ÚmapÚescapeÚkeysrS   r$   © r   r   Ú<module>r_      s�   ðó
 Û 	Û 	Û Ý ô-ô`/,ðd /6¸eØ Ÿ\™\¨WÑ4ô #ðH 
Ø	Ø	Ø	Ø	Ø
Ø
ñ€ð —’˜F S§X¡X©c°"·)±)¸_×=QÑ=QÓ=SÓ.TÓ%UÑUÓV€õ
.r   