
    4Ysh                         d dl mZmZ d dlmZ d dlmZ d dlmZm	Z	m
Z
 d dlmZ d dlmZmZ dgZ ed      Z ed	      Z G d
 de      Zy)    )IOOptional)
Serializer)	XMLWriter)URIRefLiteralBNode)	Namespace)GraphConjunctiveGraphTriXSerializerz&http://www.w3.org/2004/03/trix/trix-1/z$http://www.w3.org/XML/1998/namespacec                   \     e Zd Zdef fdZ	 	 d	dee   dee   dee   fdZ	d Z
d Z xZS )
r   storec                 Z    t         t        |   |       |j                  st	        d      y )Nz<TriX serialization only makes sense for context-aware stores)superr   __init__context_aware	Exception)selfr   	__class__s     /var/www/sten-cake5-migrate2.hellocrow.space/lexinfo-master/env/lib/python3.12/site-packages/rdflib/plugins/serializers/trix.pyr   zTriXSerializer.__init__   s0    nd,U3""N  #    streambaseencodingc                 ,   | j                   j                  }t        |||dt        i      | _        | j                  j                  t        d          |,| j                   j                  | j                   j                  }|| j                  j                  d|       | j                  j                          t        | j                   t              r1| j                   j                         D ]  }| j                  |        nWt        | j                   t              r| j                  | j                          n!t        dt        | j                         z         | j                  j!                          |j#                  dj%                  d             y )N )extra_nsTriX(http://www.w3.org/XML/1998/namespacebasezUnknown graph type: 
zlatin-1)r   namespace_managerr   TRIXNSwriterpushr   	attribute
namespaces
isinstancer   contexts_writeGraphr   r   typepopwriteencode)r   r   r   r   argsnmsubgraphs          r   	serializezTriXSerializer.serialize   s    ZZ))HF|L(<DJJOO7::??DKK!!"LdS djj"23 JJ//1 +  *+

E*TZZ(2T$**5EEFFT[[+,r   c                    | j                   j                  t        d          |j                  r&| j                   j	                  d|j                         t        |j                  t              r7| j                   j                  t        d   t        |j                               |j                  d      D ]  }| j                  |        | j                   j                          y )Ngraphr    uricontent)NNN)r$   r%   r#   r   r&   r(   
identifierr   elementstrtriples_writeTripler,   )r   r4   triples      r   r*   zTriXSerializer._writeGraph9   s    )::KK!!:EJJ e&&/KKus5;K;K7LMmm$67 	&Ff%	&r   c           	      `   | j                   j                  t        d          |D ]l  }t        |t              r.| j                   j                  t        d   t        |             Bt        |t              r.| j                   j                  t        d   t        |             t        |t              s|j                  rK| j                   j                  t        d   t        |      t        d   t        |j                        i       |j                  rL| j                   j                  t        d   t        |      t        d	   t        |j                        i       @| j                   j                  t        d   t        |             o | j                   j                          y )
Nr=   r5   r6   idtypedLiteraldatatype)r7   
attributesplainLiterallang)r$   r%   r#   r(   r   r9   r:   r	   r   rA   languageXMLNSr,   )r   r=   	components      r   r<   zTriXSerializer._writeTripleF   sG   )* 	XI)V,##F5M3y>#JIu-##F4L#i.#IIw/%%KK''~. #I$*:$6I<N<N8O#P ( 
 ''KK''~. #I$)&M3y7I7I3J#K (  KK''~(>I'W'	X( 	r   )NN)__name__
__module____qualname__r   r   r   bytesr   r:   r2   r*   r<   __classcell__)r   s   @r   r   r      sN    e  #"&	-5	- sm- 3-	->r   N)typingr   r   rdflib.serializerr   $rdflib.plugins.serializers.xmlwriterr   rdflib.termr   r   r	   rdflib.namespacer
   rdflib.graphr   r   __all__r#   rF   r    r   r   <module>rU      sJ     ( : . . & 0 
 
;	<89JZ Jr   