
    4Ysh%                     @    d dl Z d dlmZmZ dgZddiZ G d de      Zy)    N)	quoteattrescape	XMLWriterz&#13;c                   b    e Zd ZddZd Z ee      Zd Zd ZddZ	i fdZ
ddZd	 Zd
 Zd Zy)r   Nc                     |xs d}t        j                  |      \  }}}}	 |	|      x| _        }|r|j                  d|z         g | _        || _        |xs i | _        d| _        y )Nzutf-8z#<?xml version="1.0" encoding="%s"?>T)codecslookupstreamwriteelement_stacknmextra_nsclosed)
selfr   namespace_managerencodingdeclr   encoderdecoderstream_readerstream_writers
             /var/www/sten-cake5-migrate2.hellocrow.space/lexinfo-master/env/lib/python3.12/site-packages/rdflib/plugins/serializers/xmlwriter.py__init__zXMLWriter.__init__
   sj    &w9?x9P6-,V44fLL>IJ# B    c                 2    dt        | j                        z  S )Nz  )lenr   r   s    r   __get_indentzXMLWriter.__get_indent   s    c$,,---r   c                 b    | j                   s#d| _         | j                  j                  d       y y )NT>)r   r   r   r   s    r   __close_start_tagzXMLWriter.__close_start_tag   s'    {{DKKKc" r   c                 
   | j                          | j                  j                  } |d        || j                          |d| j	                  |      z         | j
                  j                  |       d| _        d| _        y )N
z<%sF)	_XMLWriter__close_start_tagr   r   indentqnamer   appendr   parent)r   urir   s      r   pushzXMLWriter.push   sg     !!ddkkedjjo%&!!#&r   c                 J   | j                   j                         }|r||k(  sJ | j                  j                  }| j                  sd| _         |d       d| _        y | j
                  r |d        || j                          |d| j                  |      z         d| _        y )NTz/>r$   z</%s>)r   popr   r   r   r)   r&   r'   )r   r*   topr   s       r   r-   zXMLWriter.pop)   s      $$&#::!!{{DK$K 	 {{ddkk"'DJJsO+,r   c                     | j                  |       |j                         D ]  \  }}| j                  ||        | j                  |       | j	                          y)z3Utility method for adding a complete simple elementN)r+   items	attributetextr-   )r   r*   content
attributeskvs         r   elementzXMLWriter.element8   sL    		#$$& 	!DAqNN1a 	!		'
r   c                 b   |s| j                   j                         }| j                  j                  } |d       |D ]1  \  }}|r |d|d|d       || j                  vs' |d|z         3 | j                  j                         D ]"  \  }}|r |d|d|d        |d|z         $ y )Nr$   z  xmlns:z="z"
z  xmlns="%s"
)r   
namespacesr   r   r   r0   )r   r9   r   prefix	namespaces        r   r9   zXMLWriter.namespaces@   s    ++-J!!d!+ 	4FIVY?@t}},&23	4 "&!4!4!6 	4FIVY?@&23		4r   c                 |    | j                   j                  } |d| j                  |      dt        |             y )N =)r   r   r'   r   )r   r*   valuer   s       r   r1   zXMLWriter.attributeS   s+    !!$**S/9U+;<=r   c                 2   | j                          d|v rZd|v rVd|vrR| j                  j                  d       | j                  j                  |       | j                  j                  d       y | j                  j                  t        |t                     y )N<r!   z]]>z	<![CDATA[)r%   r   r   r   ESCAPE_ENTITIES)r   r2   s     r   r2   zXMLWriter.textW   sq     $;3$;5+<KKk*KKd#KKe$KKfT?;<r   c                    | j                   j                         D ]K  \  }}|j                  |      s|dk7  r dj                  ||t	        |      d       c S |t	        |      d c S  | j
                  j                  |      S )zZCompute qname for a uri using our extra namespaces,
        or the given namespace manager :N)r   r0   
startswithjoinr   r   qname_strict)r   r*   prenss       r   r'   zXMLWriter.qname`   sy     }}**, 	*GC~~b!"988CSWY88s2wy>)	* ww##C((r   )N   N)N)__name__
__module____qualname__r   _XMLWriter__get_indentpropertyr&   r%   r+   r-   r7   r9   r1   r2   r'    r   r   r   r   	   sE    	. l#F#
 02 4&>=)r   )r	   xml.sax.saxutilsr   r   __all__rB   objectr   rQ   r   r   <module>rU      s)     .-/b) b)r   