
    4Ysh9
                         d Z ddlmZmZ ddlmZ ddlmZ ddlm	Z	 ddl
Z
ddlZdgZ G d de	      Z G d	 d
e      Zd Zd Zd Zd Z ej&                  de       y)z}
N-Triples RDF graph serializer for RDFLib.
See <http://www.w3.org/TR/rdf-testcases/#ntriples> for details about the
format.
    )IOOptional)Graph)Literal)
SerializerNNTSerializerc                   H    e Zd ZdZdefdZ	 	 d	dee   dee	   dee	   fdZ
y)
r   z3
    Serializes RDF graphs to NTriples format.
    storec                 0    t        j                  | |       y Nr   __init__selfr
   s     }/var/www/sten-cake5-migrate2.hellocrow.space/lexinfo-master/env/lib/python3.12/site-packages/rdflib/plugins/serializers/nt.pyr   zNTSerializer.__init__       D%(    Nstreambaseencodingc                    |t        j                  d       |dk7  rt        j                  d|        | j                  D ]*  }|j                  t	        |      j                                , |j                  dj                                y )Nz#NTSerializer does not support base.utf-8z=NTSerializer always uses UTF-8 encoding. Given encoding was: 
)warningswarnr
   write_nt_rowencode)r   r   r   r   argstriples         r   	serializezNTSerializer.serialize   sz     MM?@wMM''/j2
 jj 	3FLL//12	3T[[]#r   )Nr   )__name__
__module____qualname____doc__r   r   r   bytesr   strr!    r   r   r   r      sH    )e ) #")	$5	$ sm$ 3-	$r   c                       e Zd ZdZdefdZy)NT11Serializerze
    Serializes RDF graphs to RDF 1.1 NTriples format.

    Exactly like nt - only utf8 encoded.
    r
   c                 0    t        j                  | |       y r   r   r   s     r   r   zNT11Serializer.__init__5   r   r   N)r"   r#   r$   r%   r   r   r(   r   r   r*   r*   .   s    )e )r   r*   c                    t        | d   t              r9| d   j                         d| d   j                         dt        | d         dS | d   j                         d| d   j                         d| d   j                         dS )N   r       z .
)
isinstancer   n3_quoteLiteral)r    s    r   r   r   9   sm    &)W%1ILLN1ILLN&)$
 	
 "(PPr   c                     t        |       }| j                  r(| j                  rt        d      |d| j                  S | j                  r|d| j                  dS d|z  S )z0
    a simpler version of term.Literal.n3()
    z"Literal has datatype AND language!@z^^<>z%s)_quote_encodelanguagedatatype	Exception)l_encodeds     r   r2   r2   D   sW    
 BG	{{;;@AA!2;;//	$bkk22g~r   c                     d| j                  dd      j                  dd      j                  dd      j                  dd	      z  S )
Nz"%s"\z\\r   z\n"z\"z\r)replace)r:   s    r   r6   r6   U   sE    BJJtV,44T5AIIUgdE r   c                     d | j                   | j                  | j                   }dj                  fd|D              | j                  fS )zu
    Do unicode char replaces as defined in https://www.w3.org/TR/2004/REC-rdf-testcases-20040210/#ntrip_strings
    c                 4    t        |       } | dk  rdnd}|| z  S )Ni  z\u%04Xz\U%08X)ord)cfmts     r   _replace_singlez3_nt_unicode_error_resolver.<locals>._replace_single`   s!    F;iIQwr    c              3   .   K   | ]  } |        y wr   r(   ).0rD   rF   s     r   	<genexpr>z-_nt_unicode_error_resolver.<locals>.<genexpr>f   s     6!?1%6s   )objectstartendjoin)errstringrF   s     @r   _nt_unicode_error_resolverrQ   [   s@    

 ZZ		CGG,F776v66??r   _rdflib_nt_escape)r%   typingr   r   rdflib.graphr   rdflib.termr   rdflib.serializerr   r   codecs__all__r   r*   r   r2   r6   rQ   register_errorr(   r   r   <module>rZ      sj   
     (  
$: $8)\ )Q"@   )+E Fr   