
    4Ysh                     d    d Z ddlmZ ddlmZmZ ddlmZmZm	Z	 dgZ
 ed      Z G d de      Zy)	z2
Notation 3 (N3) RDF graph serializer for RDFLib.
    )Graph)	NamespaceOWL)TurtleSerializerSUBJECTOBJECTN3Serializerz#http://www.w3.org/2000/10/swap/log#c                        e Zd ZdZddef fdZ fdZ fdZ fdZ fdZ	 fdZ
d fd		Z fd
Zd fd	Z fdZd fd	Zd Zd Z xZS )r	   n3storec                     t         t        |   |       | j                  j	                  t
        j                  dt        j                  di       || _	        y )N=z=>)
superr	   __init__keywordsupdater   sameAsSWAP_LOGimpliesparent)selfr   r   	__class__s      }/var/www/sten-cake5-migrate2.hellocrow.space/lexinfo-master/env/lib/python3.12/site-packages/rdflib/plugins/serializers/n3.pyr   zN3Serializer.__init__   s>    lD*51cjj#x/?/?FG    c                 8    t         t        |           i | _        y N)r   r	   reset_storesr   r   s    r   r   zN3Serializer.reset   s    lD')r   c                 |    t         t        |   |       | j                  r| j                  j                  |       y y r   )r   r	   subjectDoner   r   subjectr   s     r   r!   zN3Serializer.subjectDone   s0    lD-g6;;KK##G, r   c                     t         t        |   |      xr* | j                   xs | j                  j                  |      S r   )r   r	   isDoner   r"   s     r   r%   zN3Serializer.isDone   s9    \4/8 
O:t{{11':	
r   c                 *    t         t        |           y r   )r   r	   startDocumentr   s    r   r'   zN3Serializer.startDocument$   s    lD/1r   c                 D    | j                   st        t        |           y y r   )r   r   r	   endDocumentr   s    r   r)   zN3Serializer.endDocument8   s    {{,13 r   c                     t         t        |   |      }| j                  || j                  j                         z  }|S r   )r   r	   indentr   )r   modifierr+   r   s      r   r+   zN3Serializer.indent<   s:    |T1(;;;"dkk((**Fr   c                     t         t        |   |       t        |d   t              r|d   D ]  }| j                  |        t        |d   t              r|d   D ]  }| j                  |        y y )Nr      )r   r	   preprocessTriple
isinstancer   )r   tripletr   s      r   r/   zN3Serializer.preprocessTripleB   su    lD26:fQi'AY )%%a()fQi'AY )%%a() (r   c                     d }| j                   | j                   j                  ||      }|t        t        |   ||      }|S r   )r   getQNamer   r	   )r   uri
gen_prefixqnamer   s       r   r4   zN3Serializer.getQNameK   sE    ;;"KK((j9E=,6sJGEr   c                     | j                  |       | j                  |      }t        |      dk(  ry| j                  |      xs t        t
        |   |      S )Nr   F)r!   buildPredicateHashlens_clauser   r	   	statement)r   r#   
propertiesr   s      r   r<   zN3Serializer.statementS   sP    !,,W5
z?a}}W%U|T)LW)UUr   c                 V    | j                  ||      st        t        |   |||       y y r   )p_clauser   r	   path)r   nodepositionnewliner   s       r   r@   zN3Serializer.pathZ   s)    }}T8,,*47C -r   c                     t        |t              r[| j                  d| j                         z          | j	                  |t
               | j                  |       | j                  d       yy)N
z .TF)r0   r   writer+   r?   r   predicateList)r   r#   s     r   r;   zN3Serializer.s_clause^   sQ    gu%JJtdkkm+,MM'7+w'JJtr   c                    t        |t              r| j                  |       |t        u r| j	                  d       | j	                  d       | xj
                  dz  c_        t        ||       }|j                  | j                         | xj
                  dz  c_        | j	                  | j                         dz          yy)N {   )r   }TF)
r0   r   r!   r   rF   depthr	   	serializestreamr+   )r   rA   rB   
serializers       r   r?   zN3Serializer.p_clauseh   s    dE"T"6!

3JJsOJJ!OJ%d48J  -JJ!OJJJt{{}s*+r   r   )r   )T)F)__name__
__module____qualname__
short_namer   r   r   r!   r%   r'   r)   r+   r/   r4   r<   r@   r;   r?   __classcell__)r   s   @r   r	   r	      sR    Je 
-


2(4)VDr   N)__doc__rdflib.graphr   rdflib.namespacer   r   !rdflib.plugins.serializers.turtler   r   r   __all__r   r	    r   r   <module>r\      s:     + O O
:;h# hr   