
    01i                        S r SSKJr  SSKJr  SSKJrJrJr  SSK	J
r  SSKJrJrJr  SSKJr  SSKJrJrJr  SS	KJr  S
/r\\\4   r " S S
\5      rg)a  
This is a rdflib plugin for parsing NQuad files into Conjunctive
graphs that can be used and queried. The store that backs the graph
*must* be able to handle contexts.

```python
>>> from rdflib import ConjunctiveGraph, URIRef, Namespace
>>> g = ConjunctiveGraph()
>>> data = open("test/data/nquads.rdflib/example.nquads", "rb")
>>> g.parse(data, format="nquads") # doctest:+ELLIPSIS
<Graph identifier=... (<class 'rdflib.graph.ConjunctiveGraph'>)>
>>> assert len(g.store) == 449
>>> # There should be 16 separate contexts
>>> assert len([x for x in g.store.contexts()]) == 16
>>> # is the name of entity E10009 "Arco Publications"?
>>> #   (in graph http://bibliographica.org/entity/E10009)
>>> # Looking for:
>>> # <http://bibliographica.org/entity/E10009>
>>> #   <http://xmlns.com/foaf/0.1/name>
>>> #   "Arco Publications"
>>> #   <http://bibliographica.org/entity/E10009>
>>> s = URIRef("http://bibliographica.org/entity/E10009")
>>> FOAF = Namespace("http://xmlns.com/foaf/0.1/")
>>> assert(g.value(s, FOAF.name).eq("Arco Publications"))

```
    )annotations)	getreader)AnyMutableMappingOptional)ParserError)ConjunctiveGraphDatasetGraph)InputSource)W3CNTriplesParserr_tailr_wspace)BNodeNQuadsParserc                  F    \ rS rSr  S         SS jjrSS	S jjrSrg)
r   /   Nc                H   UR                   R                  (       d   S5       e[        UR                   SS9nUR                  nSn[	        U[        [
        45      (       a  UR                  nOEUR                  b8  UR                  UR                  :X  a  UnOUR                  UR                  5      nUb  Xl        UR                  U5        X`l	        X@l
        UR                  5       n	U	(       d!  UR                  5       n	[        S5      " U	5      n	[        U	S5      (       d  [        S5      eXl        SU l         U R%                  5       =U l        n
U R&                  c   U R                  $  U R)                  U5        ME  ! [         a  n[        S	U< S
U
< 35      eSnAff = f)aL  Parse inputsource as an N-Quads file.

Args:
    inputsource: The source of N-Quads-formatted data.
    sink: The graph where parsed quads will be stored.
    bnode_context: Optional dictionary mapping blank node identifiers to
        [`BNode`][rdflib.term.BNode] instances.
        See `.W3CNTriplesParser.parse` for more details.
    skolemize: Whether to skolemize blank nodes.

Returns:
    The Dataset containing the parsed quads.

Raises:
    AssertionError: If the sink store is not context-aware.
    ParseError: If the input is not a file-like object or contains invalid lines.
z1NQuadsParser must be given a context-aware store.T)storedefault_unionNzutf-8readz)Item to parse must be a file-like object. zInvalid line (z):
)r   context_awarer
   default_context
isinstancer	   
identifierget_contextremove_graphsink	skolemizegetCharacterStreamgetByteStreamr   hasattr
ParseErrorfilebufferreadlineline	parseline)selfinputsourcer   bnode_contextr    kwargsds
ds_defaultnew_default_contextsource_NQuadsParser__linemsgs               W/home/james-whalen/.local/lib/python3.13/site-packages/rdflib/plugins/parsers/nquads.pyparseNQuadsParser.parse2   sv   4 JJ$$	?>	?$ 4::T:''
"dW&6788"&"6"6__(*"7"77&*#&(nnT__&E#*!4OOJ'	"//1 ..0Fw'/Fvv&&HII	!%0DIyy  yyK}-   K S&!IJJKs   ,E? ?
F!	FF!c                   U R                  [        5        U R                  (       a   U R                  R                  S5      (       a  g U R	                  U5      nU R                  [        5        U R                  5       nU R                  [        5        U R                  U5      nU R                  [        5        U R                  5       =(       d    U R                  U5      nU R                  [        5        U R                  (       a  [        S5      eU(       a-  U R                  R                  U5      R                  X#U45        g U R                  R                  R                  X#U45        g )N#zTrailing garbage)eatr   r(   
startswithsubject	predicateobjecturirefnodeidr   r$   r   r   addr   )r*   r,   r;   r<   objcontexts         r4   r)   NQuadsParser.parselinev   s    		dii22377,,}-NN$	kk-(++-=4;;}#=99/00 II!!'*..C/HIII%%))7s*CD    )r&   r%   r(   r   r    )NF)
r+   r   r   r   r,   Optional[_BNodeContextType]r    boolr-   r   )N)r,   rE   returnNone)__name__
__module____qualname____firstlineno__r5   r)   __static_attributes__ rD   r4   r   r   /   sR     6:B B B 3	B
 B BHE ErD   N)__doc__
__future__r   codecsr   typingr   r   r   rdflib.exceptionsr   r$   rdflib.graphr	   r
   r   rdflib.parserr   rdflib.plugins.parsers.ntriplesr   r   r   rdflib.termr   __all__str_BNodeContextTyper   rN   rD   r4   <module>r[      sX   8 #  0 0 7 9 9 % P O 
"3:. _E$ _ErD   