§
    kÃ¿aoE ã                   ó"  — d dl mZmZmZmZmZmZmZmZm	Z	m
Z
 d dlZd dlmZ d dlZd dlmZmZ d dlmZmZmZmZ d dlZd dlmZmZmZmZmZ d dlmZ d dlm Z  d d	l!m"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,m-Z- d dl.Z.d dl/Z/d dl0Z0d dl1Z1d dl2m3Z3 d dl4m5Z5 d dl6m7Z7 esJ ‚esJ ‚ ej8        e9¦  «        Z:eeef         Z;e
eeeee;         f         Z<dZ=g d¢Z> G d„ de¦  «        Z? G d„ de?¦  «        Z@ ed¦  «        ZA G d„ de@¦  «        ZB G d„ de?¦  «        ZCdejD        jE        eC<    G d„ deF¦  «        ZG G d „ d!eH¦  «        ZI G d"„ d#eH¦  «        ZJ G d$„ d%e@¦  «        ZKd&„ ZL G d'„ d(eF¦  «        ZMd)„ ZNe9d*k    r eN¦   «          dS dS )+é    )
ÚIOÚAnyÚIterableÚOptionalÚUnionÚTypeÚcastÚoverloadÚ	GeneratorÚTupleN)Úwarn)Ú	NamespaceÚRDF)ÚpluginÚ
exceptionsÚqueryÚ	namespace)ÚBNodeÚNodeÚURIRefÚLiteralÚGenid)ÚPath)ÚStore)Ú
Serializer)ÚParserÚcreate_input_source)ÚNamespaceManager)ÚResource©Ú
Collection)ÚParserError)ÚBytesIO)Úurlparse)Úurl2pathnamea%  
RDFLib defines the following kinds of Graphs:

* :class:`~rdflib.graph.Graph`
* :class:`~rdflib.graph.QuotedGraph`
* :class:`~rdflib.graph.ConjunctiveGraph`
* :class:`~rdflib.graph.Dataset`

Graph
-----

An RDF graph is a set of RDF triples. Graphs support the python ``in``
operator, as well as iteration and some operations like union,
difference and intersection.

see :class:`~rdflib.graph.Graph`

Conjunctive Graph
-----------------

A Conjunctive Graph is the most relevant collection of graphs that are
considered to be the boundary for closed world assumptions.  This
boundary is equivalent to that of the store instance (which is itself
uniquely identified and distinct from other instances of
:class:`Store` that signify other Conjunctive Graphs).  It is
equivalent to all the named graphs within it and associated with a
``_default_`` graph which is automatically assigned a :class:`BNode`
for an identifier - if one isn't given.

see :class:`~rdflib.graph.ConjunctiveGraph`

Quoted graph
------------

The notion of an RDF graph [14] is extended to include the concept of
a formula node. A formula node may occur wherever any other kind of
node can appear. Associated with a formula node is an RDF graph that
is completely disjoint from all other graphs; i.e. has no nodes in
common with any other graph. (It may contain the same labels as other
RDF graphs; because this is, by definition, a separate graph,
considerations of tidiness do not apply between the graph at a formula
node and any other graph.)

This is intended to map the idea of "{ N3-expression }" that is used
by N3 into an RDF graph upon which RDF semantics is defined.

see :class:`~rdflib.graph.QuotedGraph`

Dataset
-------

The RDF 1.1 Dataset, a small extension to the Conjunctive Graph. The
primary term is "graphs in the datasets" and not "contexts with quads"
so there is a separate method to set/retrieve a graph in a dataset and
to operate with dataset graphs. As a consequence of this approach,
dataset graphs cannot be identified with blank nodes, a name is always
required (RDFLib will automatically add a name if one is not provided
at creation time). This implementation includes a convenience method
to directly add a single quad to a dataset graph.

see :class:`~rdflib.graph.Dataset`

Working with graphs
===================

Instantiating Graphs with default store (Memory) and default identifier
(a BNode):

    >>> g = Graph()
    >>> g.store.__class__
    <class 'rdflib.plugins.stores.memory.Memory'>
    >>> g.identifier.__class__
    <class 'rdflib.term.BNode'>

Instantiating Graphs with a Memory store and an identifier -
<http://rdflib.net>:

    >>> g = Graph('Memory', URIRef("http://rdflib.net"))
    >>> g.identifier
    rdflib.term.URIRef('http://rdflib.net')
    >>> str(g)  # doctest: +NORMALIZE_WHITESPACE
    "<http://rdflib.net> a rdfg:Graph;rdflib:storage
     [a rdflib:Store;rdfs:label 'Memory']."

Creating a ConjunctiveGraph - The top level container for all named Graphs
in a "database":

    >>> g = ConjunctiveGraph()
    >>> str(g.default_context)
    "[a rdfg:Graph;rdflib:storage [a rdflib:Store;rdfs:label 'Memory']]."

Adding / removing reified triples to Graph and iterating over it directly or
via triple pattern:

    >>> g = Graph()
    >>> statementId = BNode()
    >>> print(len(g))
    0
    >>> g.add((statementId, RDF.type, RDF.Statement)) # doctest: +ELLIPSIS
    <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
    >>> g.add((statementId, RDF.subject,
    ...     URIRef("http://rdflib.net/store/ConjunctiveGraph"))) # doctest: +ELLIPSIS
    <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
    >>> g.add((statementId, RDF.predicate, namespace.RDFS.label)) # doctest: +ELLIPSIS
    <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
    >>> g.add((statementId, RDF.object, Literal("Conjunctive Graph"))) # doctest: +ELLIPSIS
    <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
    >>> print(len(g))
    4
    >>> for s, p, o in g:
    ...     print(type(s))
    ...
    <class 'rdflib.term.BNode'>
    <class 'rdflib.term.BNode'>
    <class 'rdflib.term.BNode'>
    <class 'rdflib.term.BNode'>

    >>> for s, p, o in g.triples((None, RDF.object, None)):
    ...     print(o)
    ...
    Conjunctive Graph
    >>> g.remove((statementId, RDF.type, RDF.Statement)) # doctest: +ELLIPSIS
    <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
    >>> print(len(g))
    3

``None`` terms in calls to :meth:`~rdflib.graph.Graph.triples` can be
thought of as "open variables".

Graph support set-theoretic operators, you can add/subtract graphs, as
well as intersection (with multiplication operator g1*g2) and xor (g1
^ g2).

Note that BNode IDs are kept when doing set-theoretic operations, this
may or may not be what you want. Two named graphs within the same
application probably want share BNode IDs, two graphs with data from
different sources probably not.  If your BNode IDs are all generated
by RDFLib they are UUIDs and unique.

    >>> g1 = Graph()
    >>> g2 = Graph()
    >>> u = URIRef("http://example.com/foo")
    >>> g1.add([u, namespace.RDFS.label, Literal("foo")]) # doctest: +ELLIPSIS
    <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
    >>> g1.add([u, namespace.RDFS.label, Literal("bar")]) # doctest: +ELLIPSIS
    <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
    >>> g2.add([u, namespace.RDFS.label, Literal("foo")]) # doctest: +ELLIPSIS
    <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
    >>> g2.add([u, namespace.RDFS.label, Literal("bing")]) # doctest: +ELLIPSIS
    <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
    >>> len(g1 + g2)  # adds bing as label
    3
    >>> len(g1 - g2)  # removes foo
    1
    >>> len(g1 * g2)  # only foo
    1
    >>> g1 += g2  # now g1 contains everything


Graph Aggregation - ConjunctiveGraphs and ReadOnlyGraphAggregate within
the same store:

    >>> store = plugin.get("Memory", Store)()
    >>> g1 = Graph(store)
    >>> g2 = Graph(store)
    >>> g3 = Graph(store)
    >>> stmt1 = BNode()
    >>> stmt2 = BNode()
    >>> stmt3 = BNode()
    >>> g1.add((stmt1, RDF.type, RDF.Statement)) # doctest: +ELLIPSIS
    <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
    >>> g1.add((stmt1, RDF.subject,
    ...     URIRef('http://rdflib.net/store/ConjunctiveGraph'))) # doctest: +ELLIPSIS
    <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
    >>> g1.add((stmt1, RDF.predicate, namespace.RDFS.label)) # doctest: +ELLIPSIS
    <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
    >>> g1.add((stmt1, RDF.object, Literal('Conjunctive Graph'))) # doctest: +ELLIPSIS
    <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
    >>> g2.add((stmt2, RDF.type, RDF.Statement)) # doctest: +ELLIPSIS
    <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
    >>> g2.add((stmt2, RDF.subject,
    ...     URIRef('http://rdflib.net/store/ConjunctiveGraph'))) # doctest: +ELLIPSIS
    <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
    >>> g2.add((stmt2, RDF.predicate, RDF.type)) # doctest: +ELLIPSIS
    <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
    >>> g2.add((stmt2, RDF.object, namespace.RDFS.Class)) # doctest: +ELLIPSIS
    <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
    >>> g3.add((stmt3, RDF.type, RDF.Statement)) # doctest: +ELLIPSIS
    <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
    >>> g3.add((stmt3, RDF.subject,
    ...     URIRef('http://rdflib.net/store/ConjunctiveGraph'))) # doctest: +ELLIPSIS
    <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
    >>> g3.add((stmt3, RDF.predicate, namespace.RDFS.comment)) # doctest: +ELLIPSIS
    <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
    >>> g3.add((stmt3, RDF.object, Literal(
    ...     'The top-level aggregate graph - The sum ' +
    ...     'of all named graphs within a Store'))) # doctest: +ELLIPSIS
    <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
    >>> len(list(ConjunctiveGraph(store).subjects(RDF.type, RDF.Statement)))
    3
    >>> len(list(ReadOnlyGraphAggregate([g1,g2]).subjects(
    ...     RDF.type, RDF.Statement)))
    2

ConjunctiveGraphs have a :meth:`~rdflib.graph.ConjunctiveGraph.quads` method
which returns quads instead of triples, where the fourth item is the Graph
(or subclass thereof) instance in which the triple was asserted:

    >>> uniqueGraphNames = set(
    ...     [graph.identifier for s, p, o, graph in ConjunctiveGraph(store
    ...     ).quads((None, RDF.predicate, None))])
    >>> len(uniqueGraphNames)
    3
    >>> unionGraph = ReadOnlyGraphAggregate([g1, g2])
    >>> uniqueGraphNames = set(
    ...     [graph.identifier for s, p, o, graph in unionGraph.quads(
    ...     (None, RDF.predicate, None))])
    >>> len(uniqueGraphNames)
    2

Parsing N3 from a string

    >>> g2 = Graph()
    >>> src = '''
    ... @prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
    ... @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
    ... [ a rdf:Statement ;
    ...   rdf:subject <http://rdflib.net/store#ConjunctiveGraph>;
    ...   rdf:predicate rdfs:label;
    ...   rdf:object "Conjunctive Graph" ] .
    ... '''
    >>> g2 = g2.parse(data=src, format="n3")
    >>> print(len(g2))
    4

Using Namespace class:

    >>> RDFLib = Namespace("http://rdflib.net/")
    >>> RDFLib.ConjunctiveGraph
    rdflib.term.URIRef('http://rdflib.net/ConjunctiveGraph')
    >>> RDFLib["Graph"]
    rdflib.term.URIRef('http://rdflib.net/Graph')

)	ÚGraphÚConjunctiveGraphÚQuotedGraphÚSeqÚModificationExceptionÚDatasetÚUnSupportedAggregateOperationÚReadOnlyGraphAggregateÚBatchAddGraphc                   ó¤  ‡ — e Zd ZdZ	 	 	 	 dldeeef         deeeef                  dee	         dee         fˆ fd„Z
d	„ Z ee¦  «        Zd
„ Z ee¦  «        Zd„ Zd„ Z eeed¬¦  «        Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zdmd„Zdmd„Zdeeeef         fd„Zdeeeeeef                  fd„Zd„ Z deee         ede!ef         ee         f         fd„Z"d„ Z#d„ Z$d „ Z%d!„ Z&d"„ Z'd#„ Z(d$„ Z)d%„ Z*d&„ Z+d'„ Z,d(„ Z-d)„ Z.d*„ Z/d+„ Z0d,„ Z1d-„ Z2d.„ Z3e0Z4e1Z5d/„ Z6dnd0ee         fd1„Z7dnd0ee         fd2„Z8dnd0ee         fd3„Z9dod4„Z:dod5„Z;dod6„Z<dod7„Z=de>j?        ddd8fd9„Z?dpd;„Z@ddeAjB        jC        eAjD        j@        ffd<„ZEdpd=„ZFd>„ ZGdod?„ZHdod@„ZIdodA„ZJdB„ ZKdC„ ZLdqdD„ZMdrdE„ZNdF„ ZOdsdH„ZPeQdIddJedee         dKed0eRf
dL„¦   «         ZSeQ	 	 	 dtdIddJedee         dKed0eRf
dN„¦   «         ZSeQ	 	 	 	 dudIddJedee         dKdd0ef
dO„¦   «         ZSeQ	 	 	 dtdIeeeTjU        eVeR         f         dJedee         dKee         d0d f
dP„¦   «         ZSeQ	 	 	 	 dudIeeeeTjU        eVeR         f                  dJedee         dKee         d0eeRed f         f
dQ„¦   «         ZS	 	 	 	 dvdIeeeeTjU        eVeR         f                  dJedee         dKee         dSed0eeRed f         fdT„ZSdwdV„ZW	 	 	 	 	 	 dxdJee         dWeeeeReXf                  fdX„ZYdydZ„ZZ	 	 	 	 	 dzd\eee[j\        f         d]eee]e[j^                 f         d^e_d0e[j^        fd_„Z[	 	 	 	 d{d`„Z`da„ Zadb„ Zbdc„ Zcdd„ Zdde„ Zedf„ Zfdg„ Zgdh„ Zhd|di„Zidndj„Zjdk„ Zkˆ xZlS )}r&   aw  An RDF Graph

    The constructor accepts one argument, the "store"
    that will be used to store the graph data (see the "store"
    package for stores currently shipped with rdflib).

    Stores can be context-aware or unaware.  Unaware stores take up
    (some) less space but cannot support features that require
    context, such as true merging/demerging of sub-graphs and
    provenance.

    The Graph constructor can take an identifier which identifies the Graph
    by name.  If none is given, the graph is assigned a BNode for its
    identifier.

    For more on named graphs, see: http://www.w3.org/2004/03/trix/
    ÚdefaultNÚstoreÚ
identifierÚnamespace_managerÚbasec                 óÀ  •— t          t          | ¦  «                             ¦   «          || _        |  |pt	          ¦   «         | _        t          | j        t          ¦  «        st          | j        ¦  «        | _        |  t          |t          ¦  «        s* t          j        |t          ¦  «        ¦   «         x| _        }n|| _        || _        d| _        d| _        d| _        d S ©NF)Úsuperr&   Ú__init__r4   r   Ú_Graph__identifierÚ
isinstancer   r   r   r   ÚgetÚ_Graph__storeÚ_Graph__namespace_managerÚcontext_awareÚformula_awareÚdefault_union)Úselfr1   r2   r3   r4   Ú	__class__s        €ú./usr/lib/python3/dist-packages/rdflib/graph.pyr8   zGraph.__init__G  sÎ   ø€ õ 	�e�TÑÔ×#Ò#Ñ%Ô%Ð%ØˆŒ	ØÐØ&Ð1­%©'¬'ˆÔÝ˜$Ô+­TÑ2Ô2ð 	:Ý & tÔ'8Ñ 9Ô 9ˆDÔØÐÝ˜%¥Ñ'Ô'ð 	!à#;¥6¤:¨eµUÑ#;Ô#;Ñ#=Ô#=Ð=ˆDŒL˜5˜5à ˆDŒLØ#4ˆÔ Ø"ˆÔØ"ˆÔØ"ˆÔÐÐó    c                 ó   — | j         S ©N)r<   ©rA   s    rC   Ú__get_storezGraph.__get_store_  s
   € ØŒ|ÐrD   c                 ó   — | j         S rF   )r9   rG   s    rC   Ú__get_identifierzGraph.__get_identifierd  s   € ØÔ Ð rD   c                 óF   — | j         €t          | ¦  «        | _         | j         S rF   )r=   r   rG   s    rC   Ú_get_namespace_managerzGraph._get_namespace_manageri  s$   € ØÔ#Ð+Ý'7¸Ñ'=Ô'=ˆDÔ$ØÔ'Ð'rD   c                 ó   — || _         d S rF   )r=   )rA   Únms     rC   Ú_set_namespace_managerzGraph._set_namespace_managern  s   € Ø#%ˆÔ Ð Ð rD   zthis graph's namespace-manager)Údocc                 ó8   — d| j         ›dt          | ¦  «        ›d�S )Nz<Graph identifier=z (z)>)r2   ÚtyperG   s    rC   Ú__repr__zGraph.__repr__w  s   € € Ø/3¬¨¨ÅÀTÁ
Ä
À
À
ÐKÐKrD   c                 óº   — t          | j        t          ¦  «        r.| j                             ¦   «         ›d| j        j        j        ›d�S d| j        j        j        z  S )Nz9 a rdfg:Graph;rdflib:storage [a rdflib:Store;rdfs:label 'z'].z?[a rdfg:Graph;rdflib:storage [a rdflib:Store;rdfs:label '%s']].)r:   r2   r   Ún3r1   rB   Ú__name__rG   s    rC   Ú__str__zGraph.__str__z  sf   € Ý�d”o¥vÑ.Ô.ð 	.ð ”×#Ò#Ñ%Ô%Ð%Ð% t¤zÔ';Ô'DÐ'DÐ'DðFð Fð
 WØ”
Ô$Ô-ñ.ð .rD   c                 ó   — | S rF   © rG   s    rC   ÚtoPythonzGraph.toPython„  ó   € ØˆrD   c                 ó:   — | j                              |¦  «         | S )z<Destroy the store identified by `configuration` if supported)r<   Údestroy©rA   Úconfigurations     rC   r]   zGraph.destroy‡  s   € àŒ×Ò˜]Ñ+Ô+Ð+ØˆrD   c                 ó8   — | j                              ¦   «          | S )zCommits active transactions)r<   ÚcommitrG   s    rC   ra   zGraph.commit�  s   € àŒ×ÒÑÔÐØˆrD   c                 ó8   — | j                              ¦   «          | S )zRollback active transactions)r<   ÚrollbackrG   s    rC   rc   zGraph.rollback’  s   € àŒ×ÒÑÔÐØˆrD   Fc                 ó8   — | j                              ||¦  «        S )z˜Open the graph store

        Might be necessary for stores that require opening a connection to a
        database or acquiring some resource.
        )r<   Úopen)rA   r_   Úcreates      rC   re   z
Graph.open—  s   € ð Œ|× Ò  °Ñ7Ô7Ð7rD   c                 ó8   — | j                              |¬¦  «        S )z™Close the graph store

        Might be necessary for stores that require closing a connection to a
        database or releasing some resource.
        )Úcommit_pending_transaction)r<   Úclose)rA   rh   s     rC   ri   zGraph.closeŸ  s   € ð Œ|×!Ò!Ð=WÐ!ÑXÔXÐXrD   Útriplec                 ó$  — |\  }}}t          |t          ¦  «        sJ d|›d�¦   «         ‚t          |t          ¦  «        sJ d|›d�¦   «         ‚t          |t          ¦  «        sJ d|›d�¦   «         ‚| j                             |||f| d¬¦  «         | S )ú!Add a triple with self as contextúSubject ú must be an rdflib termú
Predicate úObject F©Úquoted)r:   r   r<   Úadd©rA   rj   ÚsÚpÚos        rC   rs   z	Graph.add§  s­   € à‰ˆˆ1ˆaÝ˜!�TÑ"Ô"ÐNÐNÐNÈ1È1È1Ð$NÑNÔNÐNÝ˜!�TÑ"Ô"ÐPÐPÐPÈQÈQÈQÐ$PÑPÔPÐPÝ˜!�TÑ"Ô"ÐMÐMÐMÈ!È!È!Ð$MÑMÔMÐMØŒ×Ò˜!˜Q ˜ D°ÐÑ7Ô7Ð7ØˆrD   Úquadsc                 óT   ‡ — ‰ j                              ˆ fd„|D ¦   «         ¦  «         ‰ S )ú%Add a sequence of triple with contextc              3   ó–   •K  — | ]C\  }}}}t          |t          ¦  «        r'|j        ‰j        u ¯*t          |||¦  «        ¯;||||fV — ŒDd S rF   )r:   r&   r2   Ú_assertnode©Ú.0ru   rv   rw   ÚcrA   s        €rC   ú	<genexpr>zGraph.addN.<locals>.<genexpr>³  sx   øè è € ð 
ð 
á��1�a˜Ý˜!�UÑ#Ô#ð
ð ” ¤Ð/Ð/Ý˜A˜q !Ñ$Ô$ð 0ð ��1�aˆLð 0Ð/Ð/Ð/ð	
ð 
rD   )r<   ÚaddN©rA   rx   s   ` rC   r�   z
Graph.addN°  sL   ø€ ð 	Œ×Òð 
ð 
ð 
ð 
à#ð
ñ 
ô 
ñ 	
ô 	
ð 	
ð ˆrD   c                 ó>   — | j                              || ¬¦  «         | S )z’Remove a triple from the graph

        If the triple does not provide a context attribute, removes the triple
        from all contexts.
        ©Úcontext)r<   Úremove©rA   rj   s     rC   r†   zGraph.remove¼  s$   € ð 	Œ×Ò˜F¨DÐÑ1Ô1Ð1ØˆrD   c              #   óì   K  — |\  }}}t          |t          ¦  «        r&|                     | ||¦  «        D ]\  }}|||fV — ŒdS | j                             |||f| ¬¦  «        D ]\  \  }}}}|||fV — ŒdS )z»Generator over the triple store

        Returns triples that match the given triple pattern. If triple pattern
        does not provide a context, all contexts will be searched.
        r„   N)r:   r   Úevalr<   Útriples)rA   rj   ru   rv   rw   Ú_sÚ_oÚcgs           rC   rŠ   zGraph.triplesÅ  s´   è è € ð ‰ˆˆ1ˆaÝ�a�ÑÔð 	ØŸ&š&  q¨!Ñ,Ô,ð  ð  ‘��BØ˜!˜R�i����ð ð  ð "&¤×!5Ò!5°q¸!¸Q°iÈÐ!5Ñ!NÔ!Nð ð ‘‘	��A�q˜2Ø˜˜A�g����ðð rD   c                 óF  — t          |t          ¦  «        rÍ|j        |j        |j        }}}|€|€|€|                      |||f¦  «        S |€|€|                      |¦  «        S |€|€|                      |¦  «        S |€|€|                      |¦  «        S |€|  	                    ||¦  «        S |€|  
                    ||¦  «        S |€|                      ||¦  «        S |||f| v S t          |t          t          f¦  «        r|                      |¦  «        S t          d¦  «        ‚)aN  
        A graph can be "sliced" as a shortcut for the triples method
        The python slice syntax is (ab)used for specifying triples.
        A generator over matches is returned,
        the returned tuples include only the parts not given

        >>> import rdflib
        >>> g = rdflib.Graph()
        >>> g.add((rdflib.URIRef("urn:bob"), namespace.RDFS.label, rdflib.Literal("Bob"))) # doctest: +ELLIPSIS
        <Graph identifier=... (<class 'rdflib.graph.Graph'>)>

        >>> list(g[rdflib.URIRef("urn:bob")]) # all triples about bob
        [(rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#label'), rdflib.term.Literal('Bob'))]

        >>> list(g[:namespace.RDFS.label]) # all label triples
        [(rdflib.term.URIRef('urn:bob'), rdflib.term.Literal('Bob'))]

        >>> list(g[::rdflib.Literal("Bob")]) # all triples with bob as object
        [(rdflib.term.URIRef('urn:bob'), rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#label'))]

        Combined with SPARQL paths, more complex queries can be
        written concisely:

        Name of all Bobs friends:

        g[bob : FOAF.knows/FOAF.name ]

        Some label for Bob:

        g[bob : DC.title|FOAF.name|RDFS.label]

        All friends and friends of friends of Bob

        g[bob : FOAF.knows * "+"]

        etc.

        .. versionadded:: 4.0

        NzWYou can only index a graph by a single rdflib term or path, or a slice of rdflib terms.)r:   ÚsliceÚstartÚstopÚsteprŠ   Úsubject_predicatesÚsubject_objectsÚpredicate_objectsÚsubjectsÚ
predicatesÚobjectsr   r   Ú	TypeError)rA   Úitemru   rv   rw   s        rC   Ú__getitem__zGraph.__getitem__Õ  sE  € õT �d�EÑ"Ô"ð 	à”j $¤)¨T¬Y�!ˆqˆAØˆy˜Q˜Y¨1¨9Ø—|’| Q¨¨1 IÑ.Ô.Ð.Ø�˜q˜yØ×.Ò.¨qÑ1Ô1Ð1Ø�˜q˜yØ×+Ò+¨AÑ.Ô.Ð.Ø�˜q˜yØ×-Ò-¨aÑ0Ô0Ð0Ø�Ø—}’} Q¨Ñ*Ô*Ð*Ø�Ø—’ q¨!Ñ,Ô,Ð,Ø�Ø—|’| A qÑ)Ô)Ð)ð ˜1˜a�y DÐ(Ð(å˜�t¥T˜lÑ+Ô+ð 	à×)Ò)¨$Ñ/Ô/Ð/õ Øiñô ð rD   c                 ó8   — | j                              | ¬¦  «        S )z›Returns the number of triples in the graph

        If context is specified then the number of triples in the context is
        returned instead.
        r„   )r<   Ú__len__rG   s    rC   r�   zGraph.__len__  s   € ð Œ|×#Ò#¨DÐ#Ñ1Ô1Ð1rD   c                 ó,   — |                       d¦  «        S )z&Iterates over all triples in the store©NNN©rŠ   rG   s    rC   Ú__iter__zGraph.__iter__%  s   € à�|Š|Ð.Ñ/Ô/Ð/rD   c                 ó:   — |                       |¦  «        D ]} dS dS )z$Support for 'triple in graph' syntaxTFr    r‡   s     rC   Ú__contains__zGraph.__contains__)  s)   € à—l’l 6Ñ*Ô*ð 	ð 	ˆFØ�4�4ØˆurD   c                 ó*   — t          | j        ¦  «        S rF   )Úhashr2   rG   s    rC   Ú__hash__zGraph.__hash__/  s   € Ý�D”OÑ$Ô$Ð$rD   c                 óz   — |€dS t          |t          ¦  «        r!| j        |j        k    | j        |j        k     z
  S dS )Néÿÿÿÿé   ©r:   r&   r2   ©rA   Úothers     rC   Ú__cmp__zGraph.__cmp__2  sI   € Øˆ=Ø�2Ý˜�uÑ%Ô%ð 	Ø”O eÔ&6Ò6Ø” %Ô"2Ò2ñð ð �1rD   c                 óL   — t          |t          ¦  «        o| j        |j        k    S rF   rª   r«   s     rC   Ú__eq__zGraph.__eq__?  s!   € Ý˜%¥Ñ'Ô'ÐO¨D¬O¸uÔ?OÒ,OÐOrD   c                 óT   — |d u p$t          |t          ¦  «        o| j        |j        k     S rF   rª   r«   s     rC   Ú__lt__zGraph.__lt__B  s/   € Ø˜�ð 
Ý�u�eÑ$Ô$ÐK¨¬¸5Ô;KÒ)Kð	
rD   c                 ó   — | |k     p| |k    S rF   rY   r«   s     rC   Ú__le__zGraph.__le__G  ó   € Ø�eŠ|Ð,˜t uš}Ð,rD   c                 óT   — t          |t          ¦  «        r| j        |j        k    p|d uS rF   rª   r«   s     rC   Ú__gt__zGraph.__gt__J  s0   € Ý˜5¥%Ñ(Ô(ÐO¨T¬_¸uÔ?OÒ-Oð 
Ø˜Ðð	
rD   c                 ó   — | |k    p| |k    S rF   rY   r«   s     rC   Ú__ge__zGraph.__ge__O  r´   rD   c                 óJ   ‡ — ‰                       ˆ fd„|D ¦   «         ¦  «         ‰ S )zKAdd all triples in Graph other to Graph.
        BNode IDs are not changed.c              3   ó,   •K  — | ]\  }}}|||‰fV — Œd S rF   rY   )r~   ru   rv   rw   rA   s       €rC   r€   z!Graph.__iadd__.<locals>.<genexpr>U  s1   øè è € Ð7Ð7¡g a¨¨A�1�a˜˜D�/Ð7Ð7Ð7Ð7Ð7Ð7rD   )r�   r«   s   ` rC   Ú__iadd__zGraph.__iadd__R  s1   ø€ ð 	�	Š	Ð7Ð7Ð7Ð7°Ð7Ñ7Ô7Ñ7Ô7Ð7ØˆrD   c                 ó:   — |D ]}|                       |¦  «         Œ| S )zRSubtract all triples in Graph other from Graph.
        BNode IDs are not changed.)r†   )rA   r¬   rj   s      rC   Ú__isub__zGraph.__isub__X  s-   € ð ð 	 ð 	 ˆFØ�KŠK˜ÑÔÐÐØˆrD   c                 ó´  — 	  t          | ¦  «        ¦   «         }n# t          $ r t          ¦   «         }Y nw xY wt          t	          |                      ¦   «         ¦  «        t	          |                     ¦   «         ¦  «        z   ¦  «        D ]\  }}|                     ||¦  «         Œ| D ]}|                     |¦  «         Œ|D ]}|                     |¦  «         Œ|S )z6Set-theoretic union
        BNode IDs are not changed.)rR   r™   r&   ÚsetÚlistÚ
namespacesÚbindrs   )rA   r¬   ÚretvalÚprefixÚuriÚxÚys          rC   Ú__add__zGraph.__add___  sä   € ð	Ø•T˜$‘Z”Z‘\”\ˆFˆFøÝð 	ð 	ð 	Ý‘W”WˆFˆFˆFð	øøøå ¥ d§o¢oÑ&7Ô&7Ñ!8Ô!8½4À×@PÒ@PÑ@RÔ@RÑ;SÔ;SÑ!SÑTÔTð 	%ð 	%‰MˆV�SØ�KŠK˜ Ñ$Ô$Ð$Ð$Øð 	ð 	ˆAØ�JŠJ�q‰MŒMˆMˆMØð 	ð 	ˆAØ�JŠJ�q‰MŒMˆMˆMØˆó   ‚ š5´5c                 ó°   — 	  t          | ¦  «        ¦   «         }n# t          $ r t          ¦   «         }Y nw xY w|D ]}|| v r|                     |¦  «         Œ|S )z>Set-theoretic intersection.
        BNode IDs are not changed.©rR   r™   r&   rs   ©rA   r¬   rÃ   rÆ   s       rC   Ú__mul__zGraph.__mul__n  so   € ð	Ø•T˜$‘Z”Z‘\”\ˆFˆFøÝð 	ð 	ð 	Ý‘W”WˆFˆFˆFð	øøøàð 	ð 	ˆAØ�DˆyˆyØ—
’
˜1‘”�øØˆrÉ   c                 ó°   — 	  t          | ¦  «        ¦   «         }n# t          $ r t          ¦   «         }Y nw xY w| D ]}||vr|                     |¦  «         Œ|S )z<Set-theoretic difference.
        BNode IDs are not changed.rË   rÌ   s       rC   Ú__sub__zGraph.__sub__z  so   € ð	Ø•T˜$‘Z”Z‘\”\ˆFˆFøÝð 	ð 	ð 	Ý‘W”WˆFˆFˆFð	øøøàð 	ð 	ˆAØ˜ˆ~ˆ~Ø—
’
˜1‘”�øØˆrÉ   c                 ó   — | |z
  || z
  z   S )z5Set-theoretic XOR.
        BNode IDs are not changed.rY   r«   s     rC   Ú__xor__zGraph.__xor__†  s   € ð �u‘ ¨¡Ñ.Ð.rD   c                 ó¢   — |\  }}}|€
J d¦   «         ‚|€
J d¦   «         ‚|                       ||df¦  «         |                      |||f¦  «         | S )z¬Convenience method to update the value of object

        Remove any existing triples for subject and predicate before adding
        (subject, predicate, object).
        Nz>s can't be None in .set([s,p,o]), as it would remove (*, p, *)z>p can't be None in .set([s,p,o]), as it would remove (s, *, *))r†   rs   )rA   rj   ÚsubjectÚ	predicateÚobject_s        rC   r¿   z	Graph.set�  sw   € ð )/Ñ%ˆ�)˜WàÐÐØKñ  ÔÐð Ð!Ð!ØKñ "Ô!Ð!à�Š�W˜i¨Ð.Ñ/Ô/Ð/Ø�Š�'˜9 gÐ.Ñ/Ô/Ð/ØˆrD   Úreturnc              #   óP   K  — |                       d||f¦  «        D ]
\  }}}|V — ŒdS )z;A generator of subjects with the given predicate and objectNr    )rA   rÔ   Úobjectru   rv   rw   s         rC   r–   zGraph.subjects¡  sC   è è € à—|’| T¨9°fÐ$=Ñ>Ô>ð 	ð 	‰GˆAˆq�!ØˆGˆGˆGˆGð	ð 	rD   c              #   óP   K  — |                       |d|f¦  «        D ]
\  }}}|V — ŒdS )z;A generator of predicates with the given subject and objectNr    )rA   rÓ   rØ   ru   rv   rw   s         rC   r—   zGraph.predicates¦  sC   è è € à—|’| W¨d°FÐ$;Ñ<Ô<ð 	ð 	‰GˆAˆq�!ØˆGˆGˆGˆGð	ð 	rD   c              #   óP   K  — |                       ||df¦  «        D ]
\  }}}|V — ŒdS )z;A generator of objects with the given subject and predicateNr    )rA   rÓ   rÔ   ru   rv   rw   s         rC   r˜   zGraph.objects«  sC   è è € à—|’| W¨i¸Ð$>Ñ?Ô?ð 	ð 	‰GˆAˆq�!ØˆGˆGˆGˆGð	ð 	rD   c              #   óT   K  — |                       dd|f¦  «        D ]\  }}}||fV — ŒdS )z?A generator of (subject, predicate) tuples for the given objectNr    )rA   rØ   ru   rv   rw   s        rC   r“   zGraph.subject_predicates°  sG   è è € à—|’| T¨4°Ð$8Ñ9Ô9ð 	ð 	‰GˆAˆq�!Ø�Q�$ˆJˆJˆJˆJð	ð 	rD   c              #   óT   K  — |                       d|df¦  «        D ]\  }}}||fV — ŒdS )z?A generator of (subject, object) tuples for the given predicateNr    )rA   rÔ   ru   rv   rw   s        rC   r”   zGraph.subject_objectsµ  sG   è è € à—|’| T¨9°dÐ$;Ñ<Ô<ð 	ð 	‰GˆAˆq�!Ø�Q�$ˆJˆJˆJˆJð	ð 	rD   c              #   óT   K  — |                       |ddf¦  «        D ]\  }}}||fV — ŒdS )z?A generator of (predicate, object) tuples for the given subjectNr    )rA   rÓ   ru   rv   rw   s        rC   r•   zGraph.predicate_objectsº  sG   è è € à—|’| W¨d°DÐ$9Ñ:Ô:ð 	ð 	‰GˆAˆq�!Ø�Q�$ˆJˆJˆJˆJð	ð 	rD   c              #   óv   K  — |\  }}}| j                              |||f| ¬¦  «        D ]\  \  }}}}	|||fV — Œd S )Nr„   )r1   Útriples_choices)
rA   rj   r…   rÓ   rÔ   rÕ   ru   rv   rw   r�   s
             rC   rß   zGraph.triples_choices¿  sk   è è € Ø&,Ñ#ˆ�˜GØ!œZ×7Ò7Ø�i Ð)°4ð 8ñ 
ô 
ð 	ð 	‰M‰IˆQ��1�rð �Q˜�'ˆMˆMˆMˆMð	ð 	rD   Tc                 ó  — |}|€|�|€|�|€|€dS |€|                       ||¦  «        }|€|                      ||¦  «        }|€|                      ||¦  «        }	 t          |¦  «        }|du r‰	 t          |¦  «         d|›d|›d|›d�}| j                             |||fd¦  «        }	|	D ](\  \  }
}}}|d|
›d|›d|›dt          |¦  «        ›d�	z  }Œ)t          j        |¦  «        ‚# t          $ r Y nw xY wn# t          $ r |}Y nw xY w|S )	a  Get a value for a pair of two criteria

        Exactly one of subject, predicate, object must be None. Useful if one
        knows that there may only be one value.

        It is one of those situations that occur a lot, hence this
        'macro' like utility

        Parameters:
        subject, predicate, object  -- exactly one must be None
        default -- value to be returned if no values found
        any -- if True, return any value in the case there is more than one,
        else, raise UniquenessError
        NFz"While trying to find a value for (z, z-) the following multiple values where found:
ú(z)
 (contexts: z)
)
r˜   r–   r—   Únextr1   rŠ   rÀ   r   ÚUniquenessErrorÚStopIteration)rA   rÓ   rÔ   rØ   r0   ÚanyrÃ   ÚvaluesÚmsgrŠ   ru   rv   rw   Úcontextss                 rC   ÚvaluezGraph.valueÆ  s–  € ð" ˆð ˆ_ Ð!2Ø� F NØÐ! f nà�4àˆ>Ø—\’\ '¨9Ñ5Ô5ˆFØˆ?Ø—]’] 9¨fÑ5Ô5ˆFØÐØ—_’_ W¨fÑ5Ô5ˆFð	Ý˜&‘\”\ˆFð �eˆ|ˆ|ðÝ˜‘L”L�L�Lð #˜7˜7 I I I¨v¨v¨vð7ð ð
 #œj×0Ò0°'¸9ÀfÐ1MÈtÑTÔT�GØ/6ð ð Ñ+™	˜˜A˜q 8Ø˜Ø˜A˜AØ˜A˜AØ˜A˜AÝ  ™NœN˜N˜Nð	 ñ ˜˜õ %Ô4°SÑ9Ô9Ð9øÝ$ð ð ð Ø�Dðøøøð# øõ ð 	ð 	ð 	ØˆFˆFˆFð	øøøð, ˆs%   ÁC7 Á.A8C& Ã&
C3Ã2C3Ã7DÄDÚ c                 ó’   — t          t          d¦  «        ¦  «         |€|S |                      |t          j        j        |d¬¦  «        S )z{Query for the RDFS.label of the subject

        Return default if no label exists or any label if multiple exist.
        z@graph.label() is deprecated and will be removed in rdflib 6.0.0.NT©r0   rå   )r   ÚDeprecationWarningré   r   ÚRDFSÚlabel©rA   rÓ   r0   s      rC   rï   zGraph.label  sQ   € õ
 	ÝØRñô ñ	
ô 	
ð 	
ð
 ˆ?ØˆNØ�zŠz˜'¥9¤>Ô#7ÀÈdˆzÑSÔSÐSrD   c           
      ó&  ‡‡— t          t          d¦  «        ¦  «         |€g }‰�‰dk    rd„ }n	ˆfd„}nd„ }|D ]VŠt          t          ||                      |‰¦  «        ¦  «        ¦  «        }t          |¦  «        dk    rŒGˆfd„|D ¦   «         c S |S )	aƒ	  
        Find the preferred label for subject.

        By default prefers skos:prefLabels over rdfs:labels. In case at least
        one prefLabel is found returns those, else returns labels. In case a
        language string (e.g., "en", "de" or even "" for no lang-tagged
        literals) is given, only such labels will be considered.

        Return a list of (labelProp, label) pairs, where labelProp is either
        skos:prefLabel or rdfs:label.

        >>> from rdflib import ConjunctiveGraph, URIRef, Literal, namespace
        >>> from pprint import pprint
        >>> g = ConjunctiveGraph()
        >>> u = URIRef("http://example.com/foo")
        >>> g.add([u, namespace.RDFS.label, Literal("foo")]) # doctest: +ELLIPSIS
        <Graph identifier=... (<class 'rdflib.graph.ConjunctiveGraph'>)>
        >>> g.add([u, namespace.RDFS.label, Literal("bar")]) # doctest: +ELLIPSIS
        <Graph identifier=... (<class 'rdflib.graph.ConjunctiveGraph'>)>
        >>> pprint(sorted(g.preferredLabel(u)))
        [(rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#label'),
          rdflib.term.Literal('bar')),
         (rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#label'),
          rdflib.term.Literal('foo'))]
        >>> g.add([u, namespace.SKOS.prefLabel, Literal("bla")]) # doctest: +ELLIPSIS
        <Graph identifier=... (<class 'rdflib.graph.ConjunctiveGraph'>)>
        >>> pprint(g.preferredLabel(u))
        [(rdflib.term.URIRef('http://www.w3.org/2004/02/skos/core#prefLabel'),
          rdflib.term.Literal('bla'))]
        >>> g.add([u, namespace.SKOS.prefLabel, Literal("blubb", lang="en")]) # doctest: +ELLIPSIS
        <Graph identifier=... (<class 'rdflib.graph.ConjunctiveGraph'>)>
        >>> sorted(g.preferredLabel(u)) #doctest: +NORMALIZE_WHITESPACE
        [(rdflib.term.URIRef('http://www.w3.org/2004/02/skos/core#prefLabel'),
          rdflib.term.Literal('bla')),
          (rdflib.term.URIRef('http://www.w3.org/2004/02/skos/core#prefLabel'),
          rdflib.term.Literal('blubb', lang='en'))]
        >>> g.preferredLabel(u, lang="") #doctest: +NORMALIZE_WHITESPACE
        [(rdflib.term.URIRef('http://www.w3.org/2004/02/skos/core#prefLabel'),
          rdflib.term.Literal('bla'))]
        >>> pprint(g.preferredLabel(u, lang="en"))
        [(rdflib.term.URIRef('http://www.w3.org/2004/02/skos/core#prefLabel'),
          rdflib.term.Literal('blubb', lang='en'))]
        zIgraph.preferredLabel() is deprecated and will be removed in rdflib 6.0.0.Nrê   c                 ó   — | j         d u S rF   ©Úlanguage©Úl_s    rC   Ú
langfilterz(Graph.preferredLabel.<locals>.langfilterM  s   € Øœ;¨$Ð.Ð.rD   c                 ó   •— | j         ‰k    S rF   ró   )rö   Úlangs    €rC   r÷   z(Graph.preferredLabel.<locals>.langfilterR  s   ø€ Øœ;¨$Ò.Ð.rD   c                 ó   — dS )NTrY   rõ   s    rC   r÷   z(Graph.preferredLabel.<locals>.langfilterW  s   € Ø�trD   r   c                 ó   •— g | ]}‰|f‘ŒS rY   rY   )r~   rö   Ú	labelProps     €rC   ú
<listcomp>z(Graph.preferredLabel.<locals>.<listcomp>_  s   ø€ Ð9Ð9Ð9¨B˜ B˜Ð9Ð9Ð9rD   )r   rí   rÀ   Úfilterr˜   Úlen)rA   rÓ   rù   r0   ÚlabelPropertiesr÷   Úlabelsrü   s     `    @rC   ÚpreferredLabelzGraph.preferredLabel  sö   øø€ õd 	ÝØ[ñô ñ	
ô 	
ð 	
ð
 ˆ?ØˆGð ÐØ�rŠzˆzð/ð /ð /ð /ð
/ð /ð /ð /ð /ð /ð
ð ð ð )ð 	:ð 	:ˆIÝ�& ¨T¯\ª\¸'À9Ñ-MÔ-MÑNÔNÑOÔOˆFÝ�6‰{Œ{˜aÒÐØà9Ð9Ð9Ð9°&Ð9Ñ9Ô9Ð9Ð9Ð9ØˆrD   c                 ó’   — t          t          d¦  «        ¦  «         |€|S |                      |t          j        j        |d¬¦  «        S )z_Query for the RDFS.comment of the subject

        Return default if no comment exists
        zBgraph.comment() is deprecated and will be removed in rdflib 6.0.0.NTrì   )r   rí   ré   r   rî   Úcommentrð   s      rC   r  zGraph.commentb  sR   € õ
 	ÝØTñô ñ	
ô 	
ð 	
ð
 ˆ?ØˆNØ�zŠz˜'¥9¤>Ô#9À7ÐPTˆzÑUÔUÐUrD   c              #   ó  K  — t          |g¦  «        }|rr|                      |t          j        ¦  «        }|�|V — |                      |t          j        ¦  «        }||v rt          d¦  «        ‚|                     |¦  «         |°pdS dS )zgGenerator over all items in the resource specified by list

        list is an RDF collection.
        Nz,List contains a recursive rdf:rest reference)r¿   ré   r   ÚfirstÚrestÚ
ValueErrorrs   )rA   rÀ   Úchainrš   s       rC   ÚitemszGraph.itemsp  s›   è è € õ
 �T�F‘”ˆØð 	Ø—:’:˜d¥C¤IÑ.Ô.ˆDØÐØ�
�
�
Ø—:’:˜d¥C¤HÑ-Ô-ˆDØ�uˆ}ˆ}Ý Ð!OÑPÔPÐPØ�IŠI�d‰OŒOˆOð ð 	ð 	ð 	ð 	ð 	rD   c              #   óŒ   K  — |€i }n||v rdS d||<    ||| ¦  «        D ]$}|V — |                       |||¦  «        D ]}|V — ŒŒ%dS )a„  
        Generates transitive closure of a user-defined
        function against the graph

        >>> from rdflib.collection import Collection
        >>> g=Graph()
        >>> a=BNode("foo")
        >>> b=BNode("bar")
        >>> c=BNode("baz")
        >>> g.add((a,RDF.first,RDF.type)) # doctest: +ELLIPSIS
        <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
        >>> g.add((a,RDF.rest,b)) # doctest: +ELLIPSIS
        <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
        >>> g.add((b,RDF.first,namespace.RDFS.label)) # doctest: +ELLIPSIS
        <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
        >>> g.add((b,RDF.rest,c)) # doctest: +ELLIPSIS
        <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
        >>> g.add((c,RDF.first,namespace.RDFS.comment)) # doctest: +ELLIPSIS
        <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
        >>> g.add((c,RDF.rest,RDF.nil)) # doctest: +ELLIPSIS
        <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
        >>> def topList(node,g):
        ...    for s in g.subjects(RDF.rest, node):
        ...       yield s
        >>> def reverseList(node,g):
        ...    for f in g.objects(node, RDF.first):
        ...       print(f)
        ...    for s in g.subjects(RDF.rest, node):
        ...       yield s

        >>> [rt for rt in g.transitiveClosure(
        ...     topList,RDF.nil)] # doctest: +NORMALIZE_WHITESPACE
        [rdflib.term.BNode('baz'),
         rdflib.term.BNode('bar'),
         rdflib.term.BNode('foo')]

        >>> [rt for rt in g.transitiveClosure(
        ...     reverseList,RDF.nil)] # doctest: +NORMALIZE_WHITESPACE
        http://www.w3.org/2000/01/rdf-schema#comment
        http://www.w3.org/2000/01/rdf-schema#label
        http://www.w3.org/1999/02/22-rdf-syntax-ns#type
        [rdflib.term.BNode('baz'),
         rdflib.term.BNode('bar'),
         rdflib.term.BNode('foo')]

        Nr©   )ÚtransitiveClosure)rA   ÚfuncÚargÚseenÚrtÚrt_2s         rC   r  zGraph.transitiveClosure  s‰   è è € ð^ ˆ<ØˆDˆDØ�Dˆ[ˆ[ØˆFØˆˆS‰	Ø�$�s˜D‘/”/ð 	ð 	ˆBØˆHˆHˆHØ×.Ò.¨t°R¸Ñ>Ô>ð ð �Ø�
�
�
�
ðð	ð 	rD   c              #   óž   K  — |€i }||v rdS d||<   |V — |                       ||¦  «        D ] }|                      |||¦  «        D ]}|V — ŒŒ!dS )zÔTransitively generate objects for the ``predicate`` relationship

        Generated objects belong to the depth first transitive closure of the
        ``predicate`` relationship starting at ``subject``.
        Nr©   )r˜   Útransitive_objects)rA   rÓ   rÔ   ÚrememberrØ   rw   s         rC   r  zGraph.transitive_objects¸  sŽ   è è € ð ÐØˆHØ�hÐÐØˆFØˆ�ÑØˆˆˆØ—l’l 7¨IÑ6Ô6ð 	ð 	ˆFØ×,Ò,¨V°YÀÑIÔIð ð �Ø����ðð	ð 	rD   c              #   óž   K  — |€i }||v rdS d||<   |V — |                       ||¦  «        D ] }|                      |||¦  «        D ]}|V — ŒŒ!dS )zÕTransitively generate subjects for the ``predicate`` relationship

        Generated subjects belong to the depth first transitive closure of the
        ``predicate`` relationship starting at ``object``.
        Nr©   )r–   Útransitive_subjects)rA   rÔ   rØ   r  rÓ   ru   s         rC   r  zGraph.transitive_subjectsÈ  sŽ   è è € ð ÐØˆHØ�XÐÐØˆFØˆ�ÑØˆˆˆØ—}’} Y°Ñ7Ô7ð 	ð 	ˆGØ×-Ò-¨i¸À(ÑKÔKð ð �Ø����ðð	ð 	rD   c                 ó”   — t          t          d¦  «        ¦  «         |t          j        t          j        f| v rt	          | |¦  «        S dS )ziCheck if subject is an rdf:Seq

        If yes, it returns a Seq class instance, None otherwise.
        z>graph.seq() is deprecated and will be removed in rdflib 6.0.0.N)r   rí   r   rR   r)   )rA   rÓ   s     rC   Úseqz	Graph.seqØ  sS   € õ
 	ÝØPñô ñ	
ô 	
ð 	
ð
 •S”X�sœwÐ'¨4Ð/Ð/Ý�t˜WÑ%Ô%Ð%à�4rD   c                 ó6   — | j                              |¦  «        S rF   )r3   Úqname©rA   rÅ   s     rC   r  zGraph.qnameç  s   € ØÔ%×+Ò+¨CÑ0Ô0Ð0rD   c                 ó8   — | j                              ||¦  «        S rF   )r3   Úcompute_qname©rA   rÅ   Úgenerates      rC   r  zGraph.compute_qnameê  s   € ØÔ%×3Ò3°C¸ÑBÔBÐBrD   c                 ó>   — | j                              ||||¬¦  «        S )a6  Bind prefix to namespace

        If override is True will bind namespace to given prefix even
        if namespace was already bound to a different prefix.

        if replace, replace any existing prefix with the new namespace

        for example:  graph.bind("foaf", "http://xmlns.com/foaf/0.1/")

        )ÚoverrideÚreplace)r3   rÂ   )rA   rÄ   r   r!  r"  s        rC   rÂ   z
Graph.bindí  s-   € ð Ô%×*Ò*Ø�I¨¸'ð +ñ 
ô 
ð 	
rD   c              #   óT   K  — | j                              ¦   «         D ]\  }}||fV — ŒdS )z/Generator over all the prefix, namespace tuplesN)r3   rÁ   )rA   rÄ   r   s      rC   rÁ   zGraph.namespacesü  sG   è è € à!%Ô!7×!BÒ!BÑ!DÔ!Dð 	$ð 	$ÑˆF�IØ˜)Ð#Ð#Ð#Ð#Ð#ð	$ð 	$rD   r©   c                 ó8   — | j                              ||¦  «        S )z5Turn uri into an absolute URI if it's not one already)r3   Ú
absolutize©rA   rÅ   Údefrags      rC   r%  zGraph.absolutize  s   € àÔ%×0Ò0°°fÑ=Ô=Ð=rD   ÚdestinationÚformatÚencodingc                 ó   — d S rF   rY   ©rA   r(  r)  r4   r*  Úargss         rC   Ú	serializezGraph.serialize  s	   € ð 	ˆrD   .c                ó   — d S rF   rY   r,  s         rC   r.  zGraph.serialize  s	   € ð 	ˆrD   c                 ó   — d S rF   rY   r,  s         rC   r.  zGraph.serialize  ó	   € ð 	ˆrD   c                 ó   — d S rF   rY   r,  s         rC   r.  zGraph.serialize&  r1  rD   c                 ó   — d S rF   rY   r,  s         rC   r.  zGraph.serialize2  r1  rD   Úturtler-  c                 ó  — |€| j         } t          j        |t          ¦  «        | ¦  «        }|€mt	          ¦   «         }|€8 |j        |f|ddœ|¤Ž |                     ¦   «                              d¦  «        S  |j        |f||dœ|¤Ž |                     ¦   «         S t          |d¦  «        r3t          t          t                   |¦  «        } |j        |f||dœ|¤Ž �n)t          |t          j        ¦  «        rt          |¦  «        }nt          t          |¦  «        }t!          |¦  «        \  }	}
}}}}|
dk    rt#          d|› d�¦  «        ‚t%          j        ¦   «         \  }}t)          j        |d¦  «        } |j        |f||dœ|¤Ž |                     ¦   «          |	d	k    rt/          |¦  «        n|}t          t0          d
¦  «        rt1          j        ||¦  «         n)t1          j        ||¦  «         t)          j        |¦  «         | S )a×  Serialize the Graph to destination

        If destination is None serialize method returns the serialization as
        bytes or string.

        If encoding is None and destination is None, returns a string
        If encoding is set, and Destination is None, returns bytes

        Format defaults to turtle.

        Format support can be extended with plugins,
        but "xml", "n3", "turtle", "nt", "pretty-xml", "trix", "trig" and "nquads" are built in.
        Núutf-8)r4   r*  Úwriterê   zdestination z is not a local file referenceÚwbÚfileÚmove)r4   r   r;   r   r#   r.  ÚgetvalueÚdecodeÚhasattrr	   r   Úbytesr:   ÚpathlibÚPurePathÚstrr$   r  ÚtempfileÚmkstempÚosÚfdopenri   r%   Úshutilr:  Úcopyr†   )rA   r(  r)  r4   r*  r-  Ú
serializerÚstreamÚlocationÚschemeÚnetlocÚpathÚparamsÚ_queryÚfragmentÚfdÚnameÚdests                     rC   r.  zGraph.serialize=  s-  € ð. ˆ<Ø”9ˆDà3•V”Z ­
Ñ3Ô3°DÑ9Ô9ˆ
àÐÝ‘Y”YˆFØÐØ$�
Ô$ VÐQ°$ÀÐQÐQÈDÐQÐQÐQØ—’Ñ(Ô(×/Ò/°Ñ8Ô8Ð8à$�
Ô$ VÐR°$ÀÐRÐRÈTÐRÐRÐRØ—’Ñ(Ô(Ð(Ý�; Ñ(Ô(ð 	 Ý�"�Uœ) [Ñ1Ô1ˆFØ ˆJÔ  ÐN¨d¸XÐNÐNÈÐNÐNÐNÑNå˜+¥wÔ'7Ñ8Ô8ð 2Ý˜{Ñ+Ô+��å¥ [Ñ1Ô1�Ý=EÀhÑ=OÔ=OÑ:ˆF�F˜D &¨&°(Ø˜Š|ˆ|Ý ØN ;ÐNÐNÐNñô ð õ  Ô'Ñ)Ô)‰HˆB�Ý”Y˜r 4Ñ(Ô(ˆFØ ˆJÔ  ÐN¨d¸XÐNÐNÈÐNÐNÐNØ�LŠL‰NŒNˆNØ)/°6Ò)9Ð)9•< Ñ%Ô%Ð%¸xˆDÝ•v˜vÑ&Ô&ð  Ý”˜D $Ñ'Ô'Ð'Ð'å”˜D $Ñ'Ô'Ð'Ý”	˜$‘”�ØˆrD   r6  c                 ó|   — t          |                      d ||¬¦  «                             |¦  «        |d¬¦  «         d S )N)r)  r*  T)r9  Úflush)Úprintr.  r<  )rA   r)  r*  Úouts       rC   rV  zGraph.printz  sL   € ÝØ�NŠN˜4¨¸ˆNÑBÔB×IÒIÈ(ÑSÔSØØð	
ñ 	
ô 	
ð 	
ð 	
ð 	
rD   Údatac                 ód  — t          ||||||¬¦  «        }|€|j        }d}|€tt          |d¦  «        r^t          |j        dd¦  «        rHt          |j        j        t          ¦  «        r)t          j	         
                    |j        j        ¦  «        }|€d}d} t          j        |t          ¦  «        ¦   «         }		  |	j        || fi |¤Ž n(# t          $ r}
|rt!          d|z  ¦  «        ‚|
‚d}
~
ww xY w	 |j        r|                     ¦   «          n!# |j        r|                     ¦   «          w w xY w| S )	a	  
        Parse an RDF source adding the resulting triples to the Graph.

        The source is specified using one of source, location, file or
        data.

        :Parameters:

          - `source`: An InputSource, file-like object, or string. In the case
            of a string the string is the location of the source.
          - `location`: A string indicating the relative or absolute URL of the
            source. Graph's absolutize method is used if a relative location
            is specified.
          - `file`: A file-like object.
          - `data`: A string containing the data to be parsed.
          - `format`: Used if format can not be determined from source, e.g. file
            extension or Media Type. Defaults to text/turtle. Format support can
            be extended with plugins, but "xml", "n3" (use for turtle), "nt" &
            "trix" are built in.
          - `publicID`: the logical URI to use as the document base. If None
            specified the document location is used (at least in the case where
            there is a document location).

        :Returns:

          - self, the graph instance.

        Examples:

        >>> my_data = '''
        ... <rdf:RDF
        ...   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        ...   xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
        ... >
        ...   <rdf:Description>
        ...     <rdfs:label>Example</rdfs:label>
        ...     <rdfs:comment>This is really just an example.</rdfs:comment>
        ...   </rdf:Description>
        ... </rdf:RDF>
        ... '''
        >>> import tempfile
        >>> fd, file_name = tempfile.mkstemp()
        >>> f = os.fdopen(fd, "w")
        >>> dummy = f.write(my_data)  # Returns num bytes written
        >>> f.close()

        >>> g = Graph()
        >>> result = g.parse(data=my_data, format="application/rdf+xml")
        >>> len(g)
        2

        >>> g = Graph()
        >>> result = g.parse(location=file_name, format="application/rdf+xml")
        >>> len(g)
        2

        >>> g = Graph()
        >>> with open(file_name, "r") as f:
        ...     result = g.parse(f, format="application/rdf+xml")
        >>> len(g)
        2

        >>> os.remove(file_name)

        >>> # default turtle parsing
        >>> result = g.parse(data="<http://example.com/a> <http://example.com/a> <http://example.com/a> .")
        >>> len(g)
        3

        ©ÚsourceÚpublicIDrJ  r9  rX  r)  NFr9  rR  r4  Tz�Could not guess RDF format for %r from file extension so tried Turtle but failed.You can explicitly specify format using the format argument.)r   Úcontent_typer=  Úgetattrr9  r:   rR  rA  ÚrdflibÚutilÚguess_formatr   r;   r   ÚparseÚSyntaxErrorr"   Ú
auto_closeri   )rA   r[  r\  r)  rJ  r9  rX  r-  Úcould_not_guess_formatÚparserÚses              rC   rb  zGraph.parse�  sŠ  € õb %ØØØØØØð
ñ 
ô 
ˆð ˆ>ØÔ(ˆFØ!&ÐØˆ>å˜ Ñ'Ô'ðDå˜FœK¨°Ñ6Ô6ðDõ ˜vœ{Ô/µÑ5Ô5ðDõ
  œ×1Ò1°&´+Ô2BÑCÔC�Øˆ~Ø!�Ø)-Ð&Ø+•”˜F¥FÑ+Ô+Ñ-Ô-ˆð	àˆFŒL˜ Ð.Ð.¨Ð.Ð.Ð.Ð.øÝð 	ð 	ð 	Ø%ð Ý!ðSàññô ð ð �øøøøð	øøøð /ð Ô ð Ø—’‘”�øøð Ô ð Ø—’‘”��ðøøøàˆs*   Â:C
 Ã	D Ã

C/ÃC*Ã*C/Ã/D ÄD-Úxmlc                 óh   — t          t          d¦  «        ¦  «         |                      |||¦  «        S )Nzagraph.load() is deprecated, it will be removed in rdflib 6.0.0. Please use graph.parse() instead.)r   rí   rb  )rA   r[  r\  r)  s       rC   Úloadz
Graph.loadù  s>   € ÝÝð4ñô ñ	
ô 	
ð 	
ð �zŠz˜& (¨FÑ3Ô3Ð3rD   ÚsparqlÚ	processorÚresultÚuse_store_providedc                 ó6  — |pi }|p t          |                      ¦   «         ¦  «        }t          | j        d¦  «        r7|r5	  | j        j        |||| j        rdp| j        fi |¤ŽS # t          $ r Y nw xY wt          |t          j	        ¦  «        s2t          j        t          t          |¦  «        t          j	        ¦  «        }t          |t          j        ¦  «        s( t          j        |t          j        ¦  «        | ¦  «        } | |j        |||fi |¤Ž¦  «        S )ap  
        Query this graph.

        A type of 'prepared queries' can be realised by providing
        initial variable bindings with initBindings

        Initial namespaces are used to resolve prefixes used in the query,
        if none are given, the namespaces from the graph's namespace manager
        are used.

        :returntype: rdflib.query.Result

        r   Ú	__UNION__)ÚdictrÁ   r=  r1   r   r@   r2   ÚNotImplementedErrorr:   ÚResultr   r;   r	   rA  Ú	Processor)rA   Úquery_objectrl  rm  ÚinitNsÚinitBindingsrn  Úkwargss           rC   r   zGraph.query  s>  € ð0 $Ð) rˆØÐ2�4 §¢Ñ 1Ô 1Ñ2Ô2ˆå�4”:˜wÑ'Ô'ð 
	Ð,>ð 
	ð	Ø'�t”zÔ'Ø ØØ ØÔ&Ð6¨;ÐI¸$¼/ð	ð ð
 ðð ð øõ 'ð ð ð Ø�ðøøøõ ˜&¥%¤,Ñ/Ô/ð 	AÝ”Z¥¥S¨&Ñ 1Ô 1µ5´<Ñ@Ô@ˆFÝ˜)¥U¤_Ñ5Ô5ð 	EØ>�œ
 9­e¬oÑ>Ô>¸tÑDÔDˆIàˆv�o�i”o l°LÀ&ÐSÐSÈFÐSÐSÑTÔTÐTó   Á #A$ Á$
A1Á0A1c                 óŒ  — |pi }|p t          |                      ¦   «         ¦  «        }t          | j        d¦  «        r7|r5	  | j        j        |||| j        rdp| j        fi |¤ŽS # t          $ r Y nw xY wt          |t          j
        ¦  «        s( t          j        |t          j
        ¦  «        | ¦  «        } |j        |||fi |¤ŽS )z.Update this graph with the given update query.Úupdaterp  )rq  rÁ   r=  r1   r{  r@   r2   rr  r:   r   ÚUpdateProcessorr   r;   )rA   Úupdate_objectrl  rv  rw  rn  rx  s          rC   r{  zGraph.update0  s  € ð $Ð) rˆØÐ2�4 §¢Ñ 1Ô 1Ñ2Ô2ˆå�4”:˜xÑ(Ô(ð 
	Ð-?ð 
	ð	Ø(�t”zÔ(Ø!ØØ ØÔ&Ð6¨;ÐI¸$¼/ð	ð ð
 ðð ð øõ 'ð ð ð Ø�ðøøøõ ˜)¥UÔ%:Ñ;Ô;ð 	KØD�œ
 9­eÔ.CÑDÔDÀTÑJÔJˆIàˆyÔ ¨|¸VÐNÐNÀvÐNÐNÐNry  c                 ó:   — d| j                              ¦   «         z  S )ú%Return an n3 identifier for the Graphz[%s]©r2   rU   rG   s    rC   rU   zGraph.n3N  ó   € à˜œ×*Ò*Ñ,Ô,Ñ,Ð,rD   c                 ó,   — t           | j        | j        ffS rF   )r&   r1   r2   rG   s    rC   Ú
__reduce__zGraph.__reduce__R  s   € åà”
Ø”ðð
ð 	
rD   c                 ó>  — t          | ¦  «        t          |¦  «        k    rdS | D ]:\  }}}t          |t          ¦  «        st          |t          ¦  «        s
|||f|vr dS Œ;|D ]:\  }}}t          |t          ¦  «        st          |t          ¦  «        s
|||f| vr dS Œ;dS )zÊ
        does a very basic check if these graphs are the same
        If no BNodes are involved, this is accurate.

        See rdflib.compare for a correct implementation of isomorphism checks
        FT)rÿ   r:   r   )rA   r¬   ru   rv   rw   s        rC   Ú
isomorphiczGraph.isomorphic[  sÇ   € õ ˆt‰9Œ9�˜E™
œ
Ò"Ð"Ø�5Øð 	!ð 	!‰GˆAˆq�!Ý˜a¥Ñ'Ô'ð !µ
¸1½eÑ0DÔ0Dð !Ø˜1˜a�y EÐ)Ð)Ø ˜5˜5øØð 	!ð 	!‰GˆAˆq�!Ý˜a¥Ñ'Ô'ð !µ
¸1½eÑ0DÔ0Dð !Ø˜1˜a�y DÐ(Ð(Ø ˜5˜5øàˆtrD   c                 ó"  — t          |                      ¦   «         ¦  «        }g }|sdS |t          j        t	          |¦  «        ¦  «                 g}|r›|                     ¦   «         }||vr|                     |¦  «         |                      |¬¦  «        D ]}||vr||vr|                     |¦  «         Œ |                      |¬¦  «        D ]}||vr||vr|                     |¦  «         Œ |°›t	          |¦  «        t	          |¦  «        k    rdS dS )aˆ  Check if the Graph is connected

        The Graph is considered undirectional.

        Performs a search on the Graph, starting from a random node. Then
        iteratively goes depth-first through the triplets where the node is
        subject and object. Return True if all nodes have been visited and
        False if it cannot continue and there are still unvisited nodes left.
        F)rÓ   )rØ   T)	rÀ   Ú	all_nodesÚrandomÚ	randrangerÿ   ÚpopÚappendr˜   r–   )rA   r‡  Ú
discoveredÚvisitingrÆ   Únew_xs         rC   Ú	connectedzGraph.connectedp  s8  € õ ˜ŸšÑ)Ô)Ñ*Ô*ˆ	Øˆ
ð ð 	Ø�5à�fÔ.­s°9©~¬~Ñ>Ô>Ô?Ð@ˆØð 		+Ø—’‘”ˆAØ˜
Ð"Ð"Ø×!Ò! !Ñ$Ô$Ð$ØŸš¨a˜Ñ0Ô0ð +ð +�Ø 
Ð*Ð*¨u¸HÐ/DÐ/DØ—O’O EÑ*Ô*Ð*øØŸš¨a˜Ñ0Ô0ð +ð +�Ø 
Ð*Ð*¨u¸HÐ/DÐ/DØ—O’O EÑ*Ô*Ð*øð ð 		+õ ˆy‰>Œ>�S ™_œ_Ò,Ð,Ø�4à�5rD   c                 ó–   — t          |                      ¦   «         ¦  «        }|                     |                      ¦   «         ¦  «         |S rF   )r¿   r˜   r{  r–   )rA   Úress     rC   r‡  zGraph.all_nodes•  s6   € Ý�$—,’,‘.”.Ñ!Ô!ˆØ�
Š
�4—=’=‘?”?Ñ#Ô#Ð#Øˆ
rD   c                 ó"   — t          | |¦  «        S )aî  Create a new ``Collection`` instance.

        Parameters:

        - ``identifier``: a URIRef or BNode instance.

        Example::

            >>> graph = Graph()
            >>> uri = URIRef("http://example.org/resource")
            >>> collection = graph.collection(uri)
            >>> assert isinstance(collection, Collection)
            >>> assert collection.uri is uri
            >>> assert collection.graph is graph
            >>> collection += [ Literal(1), Literal(2) ]
        r    ©rA   r2   s     rC   Ú
collectionzGraph.collectionš  s   € õ$ ˜$ 
Ñ+Ô+Ð+rD   c                 ój   — t          |t          ¦  «        st          |¦  «        }t          | |¦  «        S )a¯  Create a new ``Resource`` instance.

        Parameters:

        - ``identifier``: a URIRef or BNode instance.

        Example::

            >>> graph = Graph()
            >>> uri = URIRef("http://example.org/resource")
            >>> resource = graph.resource(uri)
            >>> assert isinstance(resource, Resource)
            >>> assert resource.identifier is uri
            >>> assert resource.graph is graph

        )r:   r   r   r   r“  s     rC   ÚresourcezGraph.resource®  s3   € õ" ˜*¥dÑ+Ô+ð 	,Ý 
Ñ+Ô+ˆJÝ˜˜jÑ)Ô)Ð)rD   c                 ór   — |                       d¦  «        D ] }|                      ||¦  «        ¦  «         Œ!d S )NrŸ   )rŠ   rs   )rA   Útargetr  Úts       rC   Ú_process_skolem_tupleszGraph._process_skolem_tuplesÃ  sE   € Ø—’Ð0Ñ1Ô1ð 	 ð 	 ˆAØ�JŠJ�t�t˜A‘w”wÑÔÐÐð	 ð 	 rD   c                 óÚ   ‡‡‡‡— ˆˆfd„Šˆˆfd„}|€t          ¦   «         n|}‰€|                      ||¦  «         n/t          ‰t          ¦  «        r|                      |ˆˆfd„¦  «         |S )Nc                 óŽ   •— |\  }}}|| k    r|                      ‰‰¬¦  «        }|| k    r|                      ‰‰¬¦  «        }|||fS ©N)Ú	authorityÚbasepath)Ú	skolemize)Úbnoder™  ru   rv   rw   rž  rŸ  s        €€rC   Údo_skolemizez%Graph.skolemize.<locals>.do_skolemizeÈ  sU   ø€ Ø‰IˆQ��1Ø�EŠzˆzØ—K’K¨)¸h�KÑGÔG�Ø�EŠzˆzØ—K’K¨)¸h�KÑGÔG�Ø�a˜�7ˆNrD   c                 óÊ   •— | \  }}}t          |t          ¦  «        r|                     ‰‰¬¦  «        }t          |t          ¦  «        r|                     ‰‰¬¦  «        }|||fS r�  )r:   r   r   )r™  ru   rv   rw   rž  rŸ  s       €€rC   Údo_skolemize2z&Graph.skolemize.<locals>.do_skolemize2Ð  si   ø€ Ø‰IˆQ��1Ý˜!�UÑ#Ô#ð HØ—K’K¨)¸h�KÑGÔG�Ý˜!�UÑ#Ô#ð HØ—K’K¨)¸h�KÑGÔG�Ø�a˜�7ˆNrD   c                 ó   •—  ‰‰| ¦  «        S rF   rY   )r™  r¡  r¢  s    €€rC   ú<lambda>z!Graph.skolemize.<locals>.<lambda>Ý  s   ø€ ¸,¸,ÀuÈaÑ:PÔ:P€ rD   )r&   rš  r:   r   )rA   Ú	new_graphr¡  rž  rŸ  r¤  rÃ   r¢  s     ```  @rC   r   zGraph.skolemizeÇ  s¯   øøøø€ ð	ð 	ð 	ð 	ð 	ð 	ð	ð 	ð 	ð 	ð 	ð 	ð &Ð-•‘”�°9ˆàˆ=Ø×'Ò'¨°Ñ>Ô>Ð>Ð>Ý˜�uÑ%Ô%ð 	RØ×'Ò'¨Ð0PÐ0PÐ0PÐ0PÐ0PÑQÔQÐQàˆrD   c                 óÊ   ‡‡— d„ Šd„ }|€t          ¦   «         n|}‰€|                      ||¦  «         n/t          ‰t          ¦  «        r|                      |ˆˆfd„¦  «         |S )Nc                 ó€   — |\  }}}|| k    r|                      ¦   «         }|| k    r|                      ¦   «         }|||fS rF   )Úde_skolemize)Úurirefr™  ru   rv   rw   s        rC   Údo_de_skolemizez+Graph.de_skolemize.<locals>.do_de_skolemizeâ  sH   € Ø‰IˆQ��1Ø�FŠ{ˆ{Ø—N’NÑ$Ô$�Ø�FŠ{ˆ{Ø—N’NÑ$Ô$�Ø�a˜�7ˆNrD   c                 ó¼   — | \  }}}t          |t          ¦  «        r|                     ¦   «         }t          |t          ¦  «        r|                     ¦   «         }|||fS rF   )r:   r   rª  )r™  ru   rv   rw   s       rC   Údo_de_skolemize2z,Graph.de_skolemize.<locals>.do_de_skolemize2ê  sZ   € Ø‰IˆQ��1Ý˜!�UÑ#Ô#ð %Ø—N’NÑ$Ô$�Ý˜!�UÑ#Ô#ð %Ø—N’NÑ$Ô$�Ø�a˜�7ˆNrD   c                 ó   •—  ‰‰| ¦  «        S rF   rY   )r™  r¬  r«  s    €€rC   r¦  z$Graph.de_skolemize.<locals>.<lambda>÷  s   ø€ ¸/¸/È&ÐRSÑ:TÔ:T€ rD   )r&   rš  r:   r   )rA   r§  r«  r®  rÃ   r¬  s     `  @rC   rª  zGraph.de_skolemizeá  s�   øø€ ð	ð 	ð 	ð	ð 	ð 	ð &Ð-•‘”�°9ˆàˆ>Ø×'Ò'¨Ð0@ÑAÔAÐAÐAÝ˜¥Ñ&Ô&ð 	VØ×'Ò'¨Ð0TÐ0TÐ0TÐ0TÐ0TÑUÔUÐUàˆrD   c                 óL   ‡ ‡‡— t          ¦   «         Šˆˆ ˆfd„Š ‰|¦  «         ‰S )aà  Retrieves the Concise Bounded Description of a Resource from a Graph

        Concise Bounded Description (CBD) is defined in [1] as:

        Given a particular node (the starting node) in a particular RDF graph (the source graph), a subgraph of that
        particular graph, taken to comprise a concise bounded description of the resource denoted by the starting node,
        can be identified as follows:

            1. Include in the subgraph all statements in the source graph where the subject of the statement is the
                starting node;

            2. Recursively, for all statements identified in the subgraph thus far having a blank node object, include
                in the subgraph all statements in the source graph where the subject of the statement is the blank node
                in question and which are not already included in the subgraph.

            3. Recursively, for all statements included in the subgraph thus far, for all reifications of each statement
                in the source graph, include the concise bounded description beginning from the rdf:Statement node of
                each reification.

        This results in a subgraph where the object nodes are either URI references, literals, or blank nodes not
        serving as the subject of any statement in the graph.

        [1] https://www.w3.org/Submission/CBD/

        :param resource: a URIRef object, of the Resource for queried for
        :return: a Graph, subgraph of self

        c                 óŠ  •— ‰                      | d d f¦  «        D ]H\  }}}‰	                     |||f¦  «         t          |¦  «        t          k    r|d d f‰	vr ‰|¦  «         ŒI‰                      d t          j        | f¦  «        D ]=\  }}}‰                      |d d f¦  «        D ]\  }}}‰	                     |||f¦  «         ŒŒ>d S rF   )rŠ   rs   rR   r   r   rÓ   )
rÅ   ru   rv   rw   Ús2Úp2Úo2Ú
add_to_cbdrA   Úsubgraphs
          €€€rC   rµ  zGraph.cbd.<locals>.add_to_cbd  sï   ø€ ØŸ<š<¨¨d°DÐ(9Ñ:Ô:ð "ð "‘��1�aØ—’˜a  A˜YÑ'Ô'Ð'å˜‘7”7�eÒ#Ð#¨Q°°d¨O¸xÐ,GÐ,GØ�J˜q‘M”M�Møð  Ÿ<š<¨­s¬{¸CÐ(@ÑAÔAð /ð /‘��1�aà"&§,¢,°°4¸¨Ñ"?Ô"?ð /ð /‘J�B˜˜BØ—L’L " b¨" Ñ.Ô.Ð.Ð.ð/ð/ð /rD   )r&   )rA   r–  rµ  r¶  s   ` @@rC   Úcbdz	Graph.cbdû  sJ   øøø€ õ: ‘7”7ˆð	/ð 	/ð 	/ð 	/ð 	/ð 	/ð 	/ð$ 	ˆ
�8ÑÔÐàˆrD   )r0   NNN©F©NNrF   )rê   ©T)TF©r©   )...)....)Nr4  NN)r4  r6  N©NNNNNN)Nrh  )rk  rk  NNT)rk  NNT©NNNN)mrV   Ú
__module__Ú__qualname__Ú__doc__r   r   rA  r   r   r   r8   Ú_Graph__get_storeÚpropertyr1   Ú_Graph__get_identifierr2   rL   rO   r3   rS   rW   rZ   r]   ra   rc   re   ri   r   rs   r   r   r�   r†   r   rŠ   r›   r�   r¡   r£   r¦   r­   r¯   r±   r³   r¶   r¸   r»   r½   rÈ   rÍ   rÏ   rÑ   Ú__or__Ú__and__r¿   r–   r—   r˜   r“   r”   r•   rß   r   ré   rï   r   ÚSKOSÚ	prefLabelrî   r  r  r
  r  r  r  r  r  r  rÂ   rÁ   r%  r
   r>  r.  r?  r@  r   rV  Ú	bytearrayrb  rj  r   rt  r   rs  Úboolr{  rU   rƒ  r…  r�  r‡  r”  r–  rš  r   rª  r·  Ú__classcell__©rB   s   @rC   r&   r&   4  só	  ø€ € € € € ðð ð( $-Ø15Ø8<Ø"ð#ð #à�U˜C�ZÔ ð#ð ˜U 4¨ 9Ô-Ô.ð#ð $Ð$4Ô5ð	#ð
 �sŒmð#ð #ð #ð #ð #ð #ð0ð ð ð ˆH�[Ñ!Ô!€Eð!ð !ð !ð �Ð*Ñ+Ô+€Jð(ð (ð (ð
&ð &ð &ð !˜ØØØ,ðñ ô ÐðLð Lð Lð.ð .ð .ðð ð ðð ð ðð ð ð
ð ð ð
8ð 8ð 8ð 8ðYð Yð Yð Yð˜%  d¨DÐ 0Ô1ð ð ð ð ð
˜( 5¨¨t°T¸3Ð)>Ô#?Ô@ð 
ð 
ð 
ð 
ðð ð ðØ˜H TœN¨E°$¸¸dÐ2BÔ,CÀXÈdÄ^ÐSÔTðð ð ð ð Fð Fð FðP2ð 2ð 2ð0ð 0ð 0ðð ð ð%ð %ð %ðð ð ðPð Pð Pð
ð 
ð 
ð
-ð -ð -ð
ð 
ð 
ð
-ð -ð -ðð ð ðð ð ðð ð ð
ð 
ð 
ð
ð 
ð 
ð/ð /ð /ð
 €FØ€Gðð ð ð"ð °xÀ´~ð ð ð ð ð
ð °xÀ´~ð ð ð ð ð
ð °xÀ´~ð ð ð ð ð
ð ð ð ð
ð ð ð ð
ð ð ð ð
ð ð ð ð  c¤i¸ÀdÐPTð9ð 9ð 9ð 9ðvTð Tð Tð Tð" ØØ"œÔ1°9´>Ô3GÐHðQð Qð Qð QðfVð Vð Vð Vðð ð ð7ð 7ð 7ð 7ðrð ð ð ð ð ð ð ð ð ð ð1ð 1ð 1ðCð Cð Cð Cð
ð 
ð 
ð 
ð$ð $ð $ð
>ð >ð >ð >ð
 ðØðØ),ðØ4<¸S´MðØMPðà	ðð ð ñ „Xðð ð  ØØ!ð		ð 	àð	ð ð	ð �sŒmð		ð ð	ð 
ð	ð 	ð 	ñ „Xð	ð ð  ØØ!Øðð àðð ðð �sŒmð	ð
 ðð 
ðð ð ñ „Xðð ð Ø!Ø"%ðð à˜3 Ô 0°"°U´)Ð;Ô<ðð ðð �sŒmð	ð
 ˜3”-ðð 
ðð ð ñ „Xðð ð JMØØ!Ø"%ðð à˜e C¨Ô)9¸2¸e¼9Ð$DÔEÔFðð ðð �sŒmð	ð
 ˜3”-ðð 
ˆu�c˜7Ð"Ô	#ðð ð ñ „Xðð JNØØ"Ø"&ð;ð ;à˜e C¨Ô)9¸2¸e¼9Ð$DÔEÔFð;ð ð;ð �sŒmð	;ð
 ˜3”-ð;ð ð;ð 
ˆu�c˜7Ð"Ô	#ð;ð ;ð ;ð ;ðz
ð 
ð 
ð 
ð ØØ $ØØØ7;ðvð vð ˜”ð	vð �u˜S %¨Ð2Ô3Ô4ðvð vð vð vðp4ð 4ð 4ð 4ð 2:Ø19ØØØ#'ð,Uð ,Uð ˜˜eœoÐ-Ô.ð,Uð �c˜4 ¤Ô-Ð-Ô.ð	,Uð !ð,Uð 
Œð,Uð ,Uð ,Uð ,Uðb ØØØðOð Oð Oð Oð<-ð -ð -ð
ð 
ð 
ðð ð ð*#ð #ð #ðJð ð ð
,ð ,ð ,ð(*ð *ð *ð* ð  ð  ðð ð ð ð4ð ð ð ð43ð 3ð 3ð 3ð 3ð 3ð 3rD   r&   c                   ó”  ‡ — e Zd ZdZ	 	 	 d$deeef         deeeef                  dee         fˆ fd„Z	d„ Z
e	 d%d
eeeeeee         f         eeeef         f         dedeeeeee         f         fd„¦   «         Ze	 d%d
ddededddee         f         fd„¦   «         Z	 d%d
eeeeeeee         f         eeeef         f                  dedeee         ee         ee         ee         f         fd„Zd„ Zd
eeeeeee         f         eeeef         f         dd fd„Zedeeeef         defd„¦   «         Zed&d„¦   «         Zdeeeeef                  dee         fd„Zdeeeeeef                  fd„Zd„ Zd'd„Zd'd„Zd'd„Zd„ Zd'd„Z	 	 d(deeeef                  dedee         defd„Zd „ Zd'd!„Z	 	 	 	 	 	 d)d"„Zd#„ Z ˆ xZ!S )*r'   a¶  A ConjunctiveGraph is an (unnamed) aggregation of all the named
    graphs in a store.

    It has a ``default`` graph, whose name is associated with the
    graph throughout its life. :meth:`__init__` can take an identifier
    to use as the name of this default graph or it will assign a
    BNode.

    All methods that add triples work against this default graph.

    All queries are carried out against the union of all graphs.
    r0   Nr1   r2   Údefault_graph_basec                 óø   •— t          t          | ¦  «                             ||¬¦  «         | j        j        s
J d¦   «         ‚d| _        d| _        t          | j        |pt          ¦   «         |¬¦  «        | _        d S )N)r2   z9ConjunctiveGraph must be backed by a context aware store.T©r1   r2   r4   )	r7   r'   r8   r1   r>   r@   r&   r   Údefault_context)rA   r1   r2   rÍ  rB   s       €rC   r8   zConjunctiveGraph.__init__?  s�   ø€ õ 	Õ Ñ%Ô%×.Ò.¨uÀÐ.ÑLÔLÐLØŒzÔ'ð 	
ð 	
ØJñ	
ô 	
ð 	
ð "ˆÔØ!ˆÔÝ$Ø”*¨Ð)>µu±w´wÐEWð 
ñ  
ô  
ˆÔÐÐrD   c                 ó.   — d}|| j         j        j        z  S )NzK[a rdflib:ConjunctiveGraph;rdflib:storage [a rdflib:Store;rdfs:label '%s']]©r1   rB   rV   ©rA   Úpatterns     rC   rW   zConjunctiveGraph.__str__O  s!   € ð0ð 	ð ˜œÔ-Ô6Ñ6Ð6rD   FÚtriple_or_quadrÖ   c                 ó   — d S rF   rY   ©rA   rÕ  r0   s      rC   Ú_spoczConjunctiveGraph._spocV  s	   € ð 	ˆrD   c                 ó   — d S rF   rY   r×  s      rC   rØ  zConjunctiveGraph._spoc`  s	   € ð 	ˆrD   c                 óØ   — |€ddd|r| j         ndfS t          |¦  «        dk    r|r| j         nd}|\  }}}n/t          |¦  «        dk    r|\  }}}}|                      |¦  «        }||||fS )z_
        helper method for having methods that support
        either triples or quads
        Né   é   )rÐ  rÿ   Ú_graph)rA   rÕ  r0   r   ru   rv   rw   s          rC   rØ  zConjunctiveGraph._spoch  s•   € ð Ð!Ø˜$ ¸gÐ&O dÔ&:Ð&:È4ÐPÐPÝˆ~ÑÔ !Ò#Ð#Ø(/Ð9�Ô$Ð$°TˆAØ&‰IˆQ��1�1Ý�Ñ Ô  AÒ%Ð%Ø)‰LˆQ��1�aØ—’˜A‘”ˆAØ�!�Q˜ˆzÐrD   c                 óx   — |                       |¦  «        \  }}}}|                      |||f|¬¦  «        D ]} dS dS )z)Support for 'triple/quad in graph' syntaxr„   TF)rØ  rŠ   )rA   rÕ  ru   rv   rw   r   r™  s          rC   r£   zConjunctiveGraph.__contains__}  sL   € à—Z’Z Ñ/Ô/‰
ˆˆ1ˆa�Ø—’˜q ! Q˜i°�Ñ3Ô3ð 	ð 	ˆAØ�4�4ØˆurD   c                 ó    — |                       |d¬¦  «        \  }}}}t          |||¦  «         | j                             |||f|d¬¦  «         | S )zu
        Add a triple or quad to the store.

        if a triple is given it is added to the default context
        T©r0   F)r…   rr   )rØ  r|   r1   rs   ©rA   rÕ  ru   rv   rw   r   s         rC   rs   zConjunctiveGraph.add„  sX   € ð —Z’Z ¸�ZÑ=Ô=‰
ˆˆ1ˆa�å�A�q˜!ÑÔÐàŒ
�Š˜˜1˜a�y¨!°EˆÑ:Ô:Ð:ØˆrD   r   c                 ó   — d S rF   rY   ©rA   r   s     rC   rÝ  zConjunctiveGraph._graph’  ó   € àˆrD   c                 ó   — d S rF   rY   rã  s     rC   rÝ  zConjunctiveGraph._graph–  rä  rD   c                 ób   — |€d S t          |t          ¦  «        s|                      |¦  «        S |S rF   )r:   r&   Úget_contextrã  s     rC   rÝ  zConjunctiveGraph._graphš  s7   € Øˆ9Ø�4Ý˜!�UÑ#Ô#ð 	Ø×#Ò# AÑ&Ô&Ð&àˆHrD   rx   c                 óT   ‡ — ‰ j                              ˆ fd„|D ¦   «         ¦  «         ‰ S )z&Add a sequence of triples with contextc              3   óv   •K  — | ]3\  }}}}t          |||¦  «        ¯|||‰                     |¦  «        fV — Œ4d S rF   )r|   rÝ  r}   s        €rC   r€   z(ConjunctiveGraph.addN.<locals>.<genexpr>¥  se   øè è € ð 
ð 
Ù*4¨!¨Q°°1ÅÈQÐPQÐSTÑAUÔAUð
Ø��1�d—k’k !‘n”nÐ%ð
ð 
ð 
ð 
ð 
ð 
rD   ©r1   r�   r‚   s   ` rC   r�   zConjunctiveGraph.addN¢  sJ   ø€ ð 	Œ
�Šð 
ð 
ð 
ð 
Ø8=ð
ñ 
ô 
ñ 	
ô 	
ð 	
ð ˆrD   c                 óx   — |                       |¦  «        \  }}}}| j                             |||f|¬¦  «         | S )z¡
        Removes a triple or quads

        if a triple is given it is removed from all contexts

        a quad is removed from the given context only

        r„   )rØ  r1   r†   rá  s         rC   r†   zConjunctiveGraph.removeª  sC   € ð —Z’Z Ñ/Ô/‰
ˆˆ1ˆa�àŒ
×Ò˜1˜a ˜)¨QÐÑ/Ô/Ð/ØˆrD   c              #   ó†  K  — |                       |¦  «        \  }}}}|                      |p|¦  «        }| j        r|| j        k    rd}n	|€| j        }t	          |t
          ¦  «        r*|€| }|                     |||¦  «        D ]\  }}|||fV — ŒdS | j                             |||f|¬¦  «        D ]\  \  }}}}|||fV — ŒdS )a  
        Iterate over all the triples in the entire conjunctive graph

        For legacy reasons, this can take the context to query either
        as a fourth element of the quad, or as the explicit context
        keyword parameter. The kw param takes precedence.
        Nr„   )	rØ  rÝ  r@   rÐ  r:   r   r‰   r1   rŠ   )rA   rÕ  r…   ru   rv   rw   r   r�   s           rC   rŠ   zConjunctiveGraph.triples¸  s  è è € ð —Z’Z Ñ/Ô/‰
ˆˆ1ˆa�Ø—+’+˜g˜l¨Ñ+Ô+ˆàÔð 	/Ø˜$Ô.Ò.Ð.Ø�øàˆØÔ.�å�a�ÑÔð 	ØˆØ�àŸš˜w¨¨1Ñ-Ô-ð ð ‘��1Ø˜˜A�g����ðð ð "&¤×!3Ò!3°Q¸¸1°IÀwÐ!3Ñ!OÔ!Oð ð ‘‘	��A�q˜2Ø˜˜A�g����ðð rD   c              #   óª   K  — |                       |¦  «        \  }}}}| j                             |||f|¬¦  «        D ]\  \  }}}}|D ]
}||||fV — ŒŒdS )z:Iterate over all the quads in the entire conjunctive graphr„   N)rØ  r1   rŠ   )rA   rÕ  ru   rv   rw   r   r�   Úctxs           rC   rx   zConjunctiveGraph.quadsÕ  sŠ   è è € ð —Z’Z Ñ/Ô/‰
ˆˆ1ˆa�à!œZ×/Ò/°°A°q°	À1Ð/ÑEÔEð 	#ð 	#‰M‰IˆQ��1�rØð #ð #�Ø˜˜A˜s�lÐ"Ð"Ð"Ð"ð#ð	#ð 	#rD   c              #   óÂ   K  — |\  }}}|€| j         s| j        }n|                      |¦  «        }| j                             |||f|¬¦  «        D ]\  \  }}}}	|||fV — ŒdS )z<Iterate over all the triples in the entire conjunctive graphNr„   )r@   rÐ  rÝ  r1   rß   )
rA   rj   r…   ru   rv   rw   Ús1Úp1Úo1r�   s
             rC   rß   z ConjunctiveGraph.triples_choicesÞ  s�   è è € à‰ˆˆ1ˆaØˆ?ØÔ%ð /ØÔ.�øà—k’k 'Ñ*Ô*ˆGà $¤
× :Ò :¸A¸qÀ!¸9ÈgÐ :Ñ VÔ Vð 	ð 	Ñ‰LˆR��R˜"Ø�b˜"�*ÐÐÐÐð	ð 	rD   c                 ó4   — | j                              ¦   «         S )z1Number of triples in the entire conjunctive graph)r1   r�   rG   s    rC   r�   zConjunctiveGraph.__len__ê  s   € àŒz×!Ò!Ñ#Ô#Ð#rD   c              #   ó¦   K  — | j                              |¦  «        D ]3}t          |t          ¦  «        r|V — Œ|                      |¦  «        V — Œ4dS )z|Iterate over all contexts in the graph

        If triple is specified, iterate over all contexts the triple is in.
        N)r1   rè   r:   r&   rç  )rA   rj   r…   s      rC   rè   zConjunctiveGraph.contextsî  sm   è è € ð
 ”z×*Ò*¨6Ñ2Ô2ð 	0ð 	0ˆGÝ˜'¥5Ñ)Ô)ð 0ð ����à×&Ò& wÑ/Ô/Ð/Ð/Ð/Ð/ð	0ð 	0rD   rr   r4   c                 ó2   — t          | j        || |¬¦  «        S )zgReturn a context graph for the given identifier

        identifier must be a URIRef or BNode.
        )r1   r2   r3   r4   )r&   r1   )rA   r2   rr   r4   s       rC   rç  zConjunctiveGraph.get_contextü  s'   € õ Ø”*¨ÀtÐRVð
ñ 
ô 
ð 	
rD   c                 ó<   — | j                              d|¦  «         dS )z(Removes the given context from the graphrŸ   N)r1   r†   )rA   r…   s     rC   Úremove_contextzConjunctiveGraph.remove_context  s!   € àŒ
×ÒÐ,¨gÑ6Ô6Ð6Ð6Ð6rD   c                 ód   — |                      dd¦  «        d         }|€d}t          ||¬¦  «        S )zURI#contextú#r©   r   Nz#context)r4   )Úsplitr   )rA   rÅ   Ú
context_ids      rC   rû  zConjunctiveGraph.context_id  s8   € à�iŠi˜˜QÑÔ Ô"ˆØÐØ#ˆJÝ�j sÐ+Ñ+Ô+Ð+rD   c                 ó   — t          ||||||¬¦  «        }|r|p|                     ¦   «         }t          |t          ¦  «        st	          |¦  «        }t          | j        |¬¦  «        }	|	                     d¦  «          |	j        |f||dœ|¤Ž |	S )a>  
        Parse source adding the resulting triples to its own context
        (sub graph of this graph).

        See :meth:`rdflib.graph.Graph.parse` for documentation on arguments.

        :Returns:

        The graph into which the source was parsed. In the case of n3
        it returns the root context.
        rZ  ©r1   r2   rŸ   )r\  r)  )	r   ÚgetPublicIdr:   r   r   r&   r1   r†   rb  )
rA   r[  r\  r)  rJ  r9  rX  r-  Úg_idr…   s
             rC   rb  zConjunctiveGraph.parse  s±   € õ, %ØØØØØØð
ñ 
ô 
ˆð Ð$˜HÐ<¨×(:Ò(:Ñ(<Ô(<ˆÝ˜$¥Ñ%Ô%ð 	 Ý˜$‘<”<ˆDå˜dœj°TÐ:Ñ:Ô:ˆØ�ŠÐ)Ñ*Ô*Ð*ØˆŒ�fÐG x¸ÐGÐGÀ$ÐGÐGÐGàˆrD   c                 ó,   — t           | j        | j        ffS rF   )r'   r1   r2   rG   s    rC   rƒ  zConjunctiveGraph.__reduce__?  s   € Ý $¤*¨d¬oÐ!>Ð>Ð>rD   )r0   NNr¸  )r   NrÖ   NrF   )FNr¼  )"rV   r¾  r¿  rÀ  r   r   rA  r   r   r8   rW   r
   r   r   rÉ  r&   rØ  r£   rs   rÝ  r   r�   r†   rŠ   rx   rß   r�   rè   rç  r÷  rû  rb  rƒ  rÊ  rË  s   @rC   r'   r'   1  s?  ø€ € € € € ðð ð $-Ø15Ø,0ð	
ð 
à�U˜C�ZÔ ð
ð ˜U 4¨ 9Ô-Ô.ð
ð % SœMð	
ð 
ð 
ð 
ð 
ð 
ð 7ð 7ð 7ð ð ðð àØ�$˜˜d H¨S¤MÐ1Ô2°E¸$ÀÀdÐ:JÔ4KÐKô
ðð
 ðð 
ˆt�T˜4 ¨%¤Ð0Ô	1ðð ð ñ „Xðð ð ðð àðð ðð 
ˆt�T˜4 ¨%¤Ð0Ô	1ð	ð ð ñ „Xðð ðð à Ø�%˜˜d D¨(°3¬-Ð7Ô8¸%ÀÀdÈDÐ@PÔ:QÐQÔRô
ðð
 ðð 
ˆx˜Œ~˜x¨œ~¨x¸¬~¸xÈ¼ÐNÔ	Oðð ð ð ð*ð ð ð %¨¨d°D¸$ÀÈÄÐ.MÔ(NÐPUÐVZÐ\`ÐbfÐVfÔPgÐ(gÔ"hð Ðmð ð ð ð ð ð˜˜e T¨3Ð.Ô/ð °Eð ð ð ñ „Xðð ðð ð ñ „Xðð˜  u¨d°CÐ'7Ô!8Ô9ð ¸hÀu¼oð ð ð ð ð˜( 5¨¨t°T¸3Ð)>Ô#?Ô@ð ð ð ð ðð ð ðð ð ð ð:#ð #ð #ð #ð
ð 
ð 
ð 
ð$ð $ð $ð0ð 0ð 0ð 0ð" Ø"ð	
ð 
à˜U 4¨ 9Ô-Ô.ð
ð ð
ð �sŒmð	
ð
 
ð
ð 
ð 
ð 
ð7ð 7ð 7ð,ð ,ð ,ð ,ð ØØØØØð'ð 'ð 'ð 'ðR?ð ?ð ?ð ?ð ?ð ?ð ?rD   r'   zurn:x-rdflib:defaultc                   óœ   ‡ — e Zd ZdZdˆ fd„	Zd„ Zd„ Zd„ Zd	„ Zdd
„Z		 	 	 	 	 	 dd„Z
d„ Zd„ Zdˆ fd„	ZeZˆ fd„Zdeeddf         fd„Zˆ xZS )r+   a?  
    RDF 1.1 Dataset. Small extension to the Conjunctive Graph:
    - the primary term is graphs in the datasets and not contexts with quads,
    so there is a separate method to set/retrieve a graph in a dataset and
    operate with graphs
    - graphs cannot be identified with blank nodes
    - added a method to directly add a single quad

    Examples of usage:

    >>> # Create a new Dataset
    >>> ds = Dataset()
    >>> # simple triples goes to default graph
    >>> ds.add((URIRef("http://example.org/a"),
    ...    URIRef("http://www.example.org/b"),
    ...    Literal("foo")))  # doctest: +ELLIPSIS
    <Graph identifier=... (<class 'rdflib.graph.Dataset'>)>
    >>>
    >>> # Create a graph in the dataset, if the graph name has already been
    >>> # used, the corresponding graph will be returned
    >>> # (ie, the Dataset keeps track of the constituent graphs)
    >>> g = ds.graph(URIRef("http://www.example.com/gr"))
    >>>
    >>> # add triples to the new graph as usual
    >>> g.add(
    ...     (URIRef("http://example.org/x"),
    ...     URIRef("http://example.org/y"),
    ...     Literal("bar")) ) # doctest: +ELLIPSIS
    <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
    >>> # alternatively: add a quad to the dataset -> goes to the graph
    >>> ds.add(
    ...     (URIRef("http://example.org/x"),
    ...     URIRef("http://example.org/z"),
    ...     Literal("foo-bar"),g) ) # doctest: +ELLIPSIS
    <Graph identifier=... (<class 'rdflib.graph.Dataset'>)>
    >>>
    >>> # querying triples return them all regardless of the graph
    >>> for t in ds.triples((None,None,None)):  # doctest: +SKIP
    ...     print(t)  # doctest: +NORMALIZE_WHITESPACE
    (rdflib.term.URIRef("http://example.org/a"),
     rdflib.term.URIRef("http://www.example.org/b"),
     rdflib.term.Literal("foo"))
    (rdflib.term.URIRef("http://example.org/x"),
     rdflib.term.URIRef("http://example.org/z"),
     rdflib.term.Literal("foo-bar"))
    (rdflib.term.URIRef("http://example.org/x"),
     rdflib.term.URIRef("http://example.org/y"),
     rdflib.term.Literal("bar"))
    >>>
    >>> # querying quads() return quads; the fourth argument can be unrestricted
    >>> # (None) or restricted to a graph
    >>> for q in ds.quads((None, None, None, None)):  # doctest: +SKIP
    ...     print(q)  # doctest: +NORMALIZE_WHITESPACE
    (rdflib.term.URIRef("http://example.org/a"),
     rdflib.term.URIRef("http://www.example.org/b"),
     rdflib.term.Literal("foo"),
     None)
    (rdflib.term.URIRef("http://example.org/x"),
     rdflib.term.URIRef("http://example.org/y"),
     rdflib.term.Literal("bar"),
     rdflib.term.URIRef("http://www.example.com/gr"))
    (rdflib.term.URIRef("http://example.org/x"),
     rdflib.term.URIRef("http://example.org/z"),
     rdflib.term.Literal("foo-bar"),
     rdflib.term.URIRef("http://www.example.com/gr"))
    >>>
    >>> # unrestricted looping is equivalent to iterating over the entire Dataset
    >>> for q in ds:  # doctest: +SKIP
    ...     print(q)  # doctest: +NORMALIZE_WHITESPACE
    (rdflib.term.URIRef("http://example.org/a"),
     rdflib.term.URIRef("http://www.example.org/b"),
     rdflib.term.Literal("foo"),
     None)
    (rdflib.term.URIRef("http://example.org/x"),
     rdflib.term.URIRef("http://example.org/y"),
     rdflib.term.Literal("bar"),
     rdflib.term.URIRef("http://www.example.com/gr"))
    (rdflib.term.URIRef("http://example.org/x"),
     rdflib.term.URIRef("http://example.org/z"),
     rdflib.term.Literal("foo-bar"),
     rdflib.term.URIRef("http://www.example.com/gr"))
    >>>
    >>> # resticting iteration to a graph:
    >>> for q in ds.quads((None, None, None, g)):  # doctest: +SKIP
    ...     print(q)  # doctest: +NORMALIZE_WHITESPACE
    (rdflib.term.URIRef("http://example.org/x"),
     rdflib.term.URIRef("http://example.org/y"),
     rdflib.term.Literal("bar"),
     rdflib.term.URIRef("http://www.example.com/gr"))
    (rdflib.term.URIRef("http://example.org/x"),
     rdflib.term.URIRef("http://example.org/z"),
     rdflib.term.Literal("foo-bar"),
     rdflib.term.URIRef("http://www.example.com/gr"))
    >>> # Note that in the call above -
    >>> # ds.quads((None,None,None,"http://www.example.com/gr"))
    >>> # would have been accepted, too
    >>>
    >>> # graph names in the dataset can be queried:
    >>> for c in ds.graphs():  # doctest: +SKIP
    ...     print(c)  # doctest:
    DEFAULT
    http://www.example.com/gr
    >>> # A graph can be created without specifying a name; a skolemized genid
    >>> # is created on the fly
    >>> h = ds.graph()
    >>> for c in ds.graphs():  # doctest: +SKIP
    ...     print(c)  # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
    DEFAULT
    http://rdlib.net/.well-known/genid/rdflib/N...
    http://www.example.com/gr
    >>> # Note that the Dataset.graphs() call returns names of empty graphs,
    >>> # too. This can be restricted:
    >>> for c in ds.graphs(empty=False):  # doctest: +SKIP
    ...     print(c)  # doctest: +NORMALIZE_WHITESPACE
    DEFAULT
    http://www.example.com/gr
    >>>
    >>> # a graph can also be removed from a dataset via ds.remove_graph(g)

    .. versionadded:: 4.0
    r0   FNc                 óâ   •— t          t          | ¦  «                             |d ¬¦  «         | j        j        st          d¦  «        ‚t          | j        t          |¬¦  «        | _        || _	        d S )Nrý  z.DataSet must be backed by a graph-aware store!rÏ  )
r7   r+   r8   r1   Úgraph_awareÚ	Exceptionr&   ÚDATASET_DEFAULT_GRAPH_IDrÐ  r@   )rA   r1   r@   rÍ  rB   s       €rC   r8   zDataset.__init__Á  su   ø€ Ý�g�tÑÔ×%Ò%¨E¸dÐ%ÑCÔCÐCàŒzÔ%ð 	NÝÐLÑMÔMÐMÝ$Ø”*Ý/Ø#ð 
ñ  
ô  
ˆÔð +ˆÔÐÐrD   c                 ó.   — d}|| j         j        j        z  S )NzB[a rdflib:Dataset;rdflib:storage [a rdflib:Store;rdfs:label '%s']]rÒ  rÓ  s     rC   rW   zDataset.__str__Î  s   € àSð 	ð ˜œÔ-Ô6Ñ6Ð6rD   c                 ó<   — t          | ¦  «        | j        | j        ffS rF   )rR   r1   r@   rG   s    rC   rƒ  zDataset.__reduce__Ô  s   € Ý�T‘
”
˜TœZ¨Ô);Ð<Ð=Ð=rD   c                 ó6   — | j         | j        | j        | j        fS rF   ©r1   r2   rÐ  r@   rG   s    rC   Ú__getstate__zDataset.__getstate__×  s   € ØŒz˜4œ?¨DÔ,@À$ÔBTÐTÐTrD   c                 ó<   — |\  | _         | _        | _        | _        d S rF   r	  )rA   Ústates     rC   Ú__setstate__zDataset.__setstate__Ú  s    € ØPUÑMˆŒ
�D”O TÔ%9¸4Ô;MÐ;MÐ;MrD   c                 óø   — |€Addl m} |                      dd|z   d¬¦  «         t          ¦   «                              ¦   «         }|                      |¦  «        }||_        | j                             |¦  «         |S )Nr   )Úrdflib_skolem_genidÚgenidzhttp://rdflib.netF)r!  )	Úrdflib.termr  rÂ   r   r   rÝ  r4   r1   Ú	add_graph)rA   r2   r4   r  Úgs        rC   ÚgraphzDataset.graphÝ  s�   € ØÐØ7Ð7Ð7Ð7Ð7Ð7à�IŠIØÐ,Ð/BÑBÈUð ñ ô ð õ ™œ×*Ò*Ñ,Ô,ˆJà�KŠK˜
Ñ#Ô#ˆØˆŒàŒ
×Ò˜QÑÔÐØˆrD   c           	      ó`   — t          j        | ||||||fi |¤Ž}|                      |¦  «         |S rF   )r'   rb  r  )	rA   r[  r\  r)  rJ  r9  rX  r-  r   s	            rC   rb  zDataset.parseì  sH   € õ Ô"Ø�&˜( F¨H°d¸Dð
ð 
ØDHð
ð 
ˆð 	�
Š
�1‰ŒˆØˆrD   c                 ó,   — |                       |¦  «        S )zalias of graph for consistency)r  ©rA   r  s     rC   r  zDataset.add_graphü  s   € à�zŠz˜!‰}Œ}ÐrD   c                 óæ   — t          |t          ¦  «        s|                      |¦  «        }| j                             |¦  «         |�|| j        k    r| j                             | j        ¦  «         | S rF   )r:   r&   rç  r1   Úremove_graphrÐ  r  r  s     rC   r  zDataset.remove_graph   so   € Ý˜!�UÑ#Ô#ð 	$Ø× Ò  Ñ#Ô#ˆAàŒ
×Ò Ñ"Ô"Ð"Øˆ9˜˜TÔ1Ò1Ð1ð ŒJ× Ò  Ô!5Ñ6Ô6Ð6ØˆrD   c              #   óÔ   •K  — d}t          t          | ¦  «                             |¦  «        D ]}||j        t          k    z  }|V — Œ|s|                      t          ¦  «        V — d S d S r6   )r7   r+   rè   r2   r  r  )rA   rj   r0   r   rB   s       €rC   rè   zDataset.contexts  s�   øè è € ØˆÝ•w Ñ%Ô%×.Ò.¨vÑ6Ô6ð 	ð 	ˆAØ�q”|Õ'?Ò?Ñ?ˆGØˆGˆGˆGˆGØð 	7Ø—*’*Õ5Ñ6Ô6Ð6Ð6Ð6Ð6Ð6ð	7ð 	7rD   c              #   ó¸   •K  — t          t          | ¦  «                             |¦  «        D ]-\  }}}}|j        | j        k    r	|||d fV — Œ ||||j        fV — Œ.d S rF   )r7   r+   rx   r2   rÐ  )rA   Úquadru   rv   rw   r   rB   s         €rC   rx   zDataset.quads  s�   øè è € Ý¥¨Ñ.Ô.×4Ò4°TÑ:Ô:ð 	,ð 	,‰JˆAˆq�!�QØŒ|˜tÔ3Ò3Ð3Ø˜˜A˜t�mÐ#Ð#Ð#Ð#à˜˜A˜qœ|Ð+Ð+Ð+Ð+Ð+ð		,ð 	,rD   rÖ   c                 ó,   — |                       d¦  «        S )z$Iterates over all quads in the storer½  )rx   rG   s    rC   r¡   zDataset.__iter__  s   € à�zŠzÐ2Ñ3Ô3Ð3rD   )r0   FNr¹  r¼  rF   )rV   r¾  r¿  rÀ  r8   rW   rƒ  r
  r  r  rb  r  r  rè   Úgraphsrx   r   ÚDatasetQuadr¡   rÊ  rË  s   @rC   r+   r+   F  sG  ø€ € € € € ðx€Gðt+ð +ð +ð +ð +ð +ð7ð 7ð 7ð>ð >ð >ðUð Uð UðVð Vð Vðð ð ð ð" ØØØØØðð ð ð ð ð ð ð	ð 	ð 	ð7ð 7ð 7ð 7ð 7ð 7ð €Fð,ð ,ð ,ð ,ð ,ð4˜) K°°tÐ$;Ô<ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4rD   r+   c                   óv   ‡ — e Zd ZdZˆ fd„Zdeeeef         fd„Zdeeeeef         dd fd„Z	d„ Z
d	„ Zd
„ Zˆ xZS )r(   a  
    Quoted Graphs are intended to implement Notation 3 formulae. They are
    associated with a required identifier that the N3 parser *must* provide
    in order to maintain consistent formulae identification for scenarios
    such as implication and other such processing.
    c                 óZ   •— t          t          | ¦  «                             ||¦  «         d S rF   )r7   r(   r8   )rA   r1   r2   rB   s      €rC   r8   zQuotedGraph.__init__)  s)   ø€ Ý�k˜4Ñ Ô ×)Ò)¨%°Ñ<Ô<Ð<Ð<Ð<rD   rj   c                 ó$  — |\  }}}t          |t          ¦  «        sJ d|›d�¦   «         ‚t          |t          ¦  «        sJ d|›d�¦   «         ‚t          |t          ¦  «        sJ d|›d�¦   «         ‚| j                             |||f| d¬¦  «         | S )rl   rm   rn   ro   rp   Trq   )r:   r   r1   rs   rt   s        rC   rs   zQuotedGraph.add,  sª   € à‰ˆˆ1ˆaÝ˜!�TÑ"Ô"ÐNÐNÐNÈ1È1È1Ð$NÑNÔNÐNÝ˜!�TÑ"Ô"ÐPÐPÐPÈQÈQÈQÐ$PÑPÔPÐPÝ˜!�TÑ"Ô"ÐMÐMÐMÈ!È!È!Ð$MÑMÔMÐMàŒ
�Š˜˜1˜a�y $¨tˆÑ4Ô4Ð4ØˆrD   rx   rÖ   c                 óT   ‡ — ‰ j                              ˆ fd„|D ¦   «         ¦  «         ‰ S )rz   c              3   ó–   •K  — | ]C\  }}}}t          |t          ¦  «        r'|j        ‰j        u ¯*t          |||¦  «        ¯;||||fV — ŒDd S rF   )r:   r(   r2   r|   r}   s        €rC   r€   z#QuotedGraph.addN.<locals>.<genexpr>9  sx   øè è € ð 
ð 
á��1�a˜Ý˜!�[Ñ)Ô)ð
ð ” ¤Ð/Ð/Ý˜A˜q !Ñ$Ô$ð 0ð ��1�aˆLð 0Ð/Ð/Ð/ð	
ð 
rD   rê  r‚   s   ` rC   r�   zQuotedGraph.addN6  sJ   ø€ ð 	Œ
�Šð 
ð 
ð 
ð 
à#ð
ñ 
ô 
ñ 	
ô 	
ð 	
ð ˆrD   c                 ó:   — d| j                              ¦   «         z  S )r  z{%s}r€  rG   s    rC   rU   zQuotedGraph.n3B  r�  rD   c                 óh   — | j                              ¦   «         }| j        j        j        }d}|||fz  S )NzK{this rdflib.identifier %s;rdflib:storage [a rdflib:Store;rdfs:label '%s']})r2   rU   r1   rB   rV   )rA   r2   rï   rÔ  s       rC   rW   zQuotedGraph.__str__F  s>   € Ø”_×'Ò'Ñ)Ô)ˆ
Ø”
Ô$Ô-ˆð0ð 	ð ˜* eÐ,Ñ,Ð,rD   c                 ó,   — t           | j        | j        ffS rF   )r(   r1   r2   rG   s    rC   rƒ  zQuotedGraph.__reduce__O  s   € Ý˜TœZ¨¬Ð9Ð9Ð9rD   )rV   r¾  r¿  rÀ  r8   r   r   rs   r   r�   rU   rW   rƒ  rÊ  rË  s   @rC   r(   r(   !  sÆ   ø€ € € € € ðð ð=ð =ð =ð =ð =ð˜%  d¨DÐ 0Ô1ð ð ð ð ð
˜%  d¨D°#Ð 5Ô6ð 
¸=ð 
ð 
ð 
ð 
ð-ð -ð -ð-ð -ð -ð:ð :ð :ð :ð :ð :ð :rD   r(   é   c                   ó0   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ ZdS )r)   a.  Wrapper around an RDF Seq resource

    It implements a container type in Python with the order of the items
    returned corresponding to the Seq content. It is based on the natural
    ordering of the predicate names _1, _2, _3, etc, which is the
    'implementation' of a sequence in RDF terms.
    c                 ót  — t          ¦   «         x}| _        t          t          t          ¦  «        dz   ¦  «        }|                     |¦  «        D ]T\  }}|                     |¦  «        r:t          |                     |d¦  «        ¦  «        }| 	                    ||f¦  «         ŒU| 
                    ¦   «          dS )a  Parameters:

        - graph:
            the graph containing the Seq

        - subject:
            the subject of a Seq. Note that the init does not
            check whether this is a Seq, this is done in whoever
            creates this instance!
        Ú_rê   N)rÀ   Ú_listr   rA  r   r•   Ú
startswithÚintr"  r‹  Úsort)rA   r  rÓ   r,  ÚLI_INDEXrv   rw   Úis           rC   r8   zSeq.__init__c  s¥   € õ "™VœVÐ#ˆ�”
Ý�#�c™(œ( S™.Ñ)Ô)ˆØ×-Ò-¨gÑ6Ô6ð 	%ð 	%‰FˆQ�Ø�|Š|˜HÑ%Ô%ð %Ý˜Ÿ	š	 (¨BÑ/Ô/Ñ0Ô0�Ø—’˜a ˜VÑ$Ô$Ð$øð 	�
Š
‰ŒˆˆˆrD   c                 ó   — | S rF   rY   rG   s    rC   rZ   zSeq.toPythonz  r[   rD   c              #   ó,   K  — | j         D ]	\  }}|V — Œ
dS )z#Generator over the items in the SeqN)r,  )rA   r+  rš   s      rC   r¡   zSeq.__iter__}  s0   è è € à”zð 	ð 	‰GˆAˆtØˆJˆJˆJˆJð	ð 	rD   c                 ó*   — t          | j        ¦  «        S )zLength of the Seq)rÿ   r,  rG   s    rC   r�   zSeq.__len__‚  s   € å�4”:‰ŒÐrD   c                 ó@   — | j                              |¦  «        \  }}|S )z Item given by index from the Seq)r,  r›   )rA   Úindexrš   s      rC   r›   zSeq.__getitem__†  s    € à”j×,Ò,¨UÑ3Ô3‰ˆˆtØˆrD   N)	rV   r¾  r¿  rÀ  r8   rZ   r¡   r�   r›   rY   rD   rC   r)   r)   Z  si   € € € € € ðð ðð ð ð.ð ð ðð ð ð
ð ð ðð ð ð ð rD   r)   c                   ó   — e Zd Zd„ Zd„ ZdS )r*   c                 ó   — d S rF   rY   rG   s    rC   r8   zModificationException.__init__�  ó   € ØˆrD   c                 ó   — 	 dS )NzZModifications and transactional operations not allowed on ReadOnlyGraphAggregate instancesrY   rG   s    rC   rW   zModificationException.__str__�  s   € ð/ð	
ð 	
rD   N©rV   r¾  r¿  r8   rW   rY   rD   rC   r*   r*   Œ  s2   € € € € € ðð ð ð
ð 
ð 
ð 
ð 
rD   r*   c                   ó   — e Zd Zd„ Zd„ ZdS )r,   c                 ó   — d S rF   rY   rG   s    rC   r8   z&UnSupportedAggregateOperation.__init__˜  r9  rD   c                 ó   — dS )NzCThis operation is not supported by ReadOnlyGraphAggregate instancesrY   rG   s    rC   rW   z%UnSupportedAggregateOperation.__str__›  s   € ØWÐWrD   Nr;  rY   rD   rC   r,   r,   —  s7   € € € € € ðð ð ðXð Xð Xð Xð XrD   r,   c                   óÌ   ‡ — e Zd ZdZd"ˆ fd„	Zd„ Zd„ Zd„ Zd„ Zd#d	„Z	d
„ Z
d„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd$d„Zd„ Zd%d„Zd%d„Zd„ Zd&d„Zd'd„Zd „ Zd!„ Zˆ xZS )(r-   zËUtility class for treating a set of graphs as a single graph

    Only read operations are supported (hence the name). Essentially a
    ConjunctiveGraph over an explicit subset of the entire store.
    r0   c                 ó  •— |�Jt          t          | ¦  «                             |¦  «         t                               | |¦  «         d | _        t          |t          ¦  «        r|rd„ |D ¦   «         s
J d¦   «         ‚|| _        d S )Nc                 ó<   — g | ]}t          |t          ¦  «        ¯|‘ŒS rY   )r:   r&   ©r~   r  s     rC   rý   z3ReadOnlyGraphAggregate.__init__.<locals>.<listcomp>¯  s'   € Ð;Ð;Ð;�q¥j°µEÑ&:Ô&:Ð;�Ð;Ð;Ð;rD   z*graphs argument must be a list of Graphs!!)r7   r-   r8   r&   Ú*_ReadOnlyGraphAggregate__namespace_managerr:   rÀ   r  )rA   r  r1   rB   s      €rC   r8   zReadOnlyGraphAggregate.__init__¦  sž   ø€ ØÐÝÕ(¨$Ñ/Ô/×8Ò8¸Ñ?Ô?Ð?Ý�NŠN˜4 Ñ'Ô'Ð'Ø'+ˆDÔ$õ �v�tÑ$Ô$ð	8àð	8ð <Ð;˜FÐ;Ñ;Ô;ð	8ð 	8ð 8ñ		8ô 	8ð 	8ð
 ˆŒˆˆrD   c                 ó0   — dt          | j        ¦  «        z  S )Nz#<ReadOnlyGraphAggregate: %s graphs>)rÿ   r  rG   s    rC   rS   zReadOnlyGraphAggregate.__repr__³  s   € Ø4µs¸4¼;Ñ7GÔ7GÑGÐGrD   c                 ó   — t          ¦   «         ‚rF   ©r*   r^   s     rC   r]   zReadOnlyGraphAggregate.destroy¶  ó   € Ý#Ñ%Ô%Ð%rD   c                 ó   — t          ¦   «         ‚rF   rF  rG   s    rC   ra   zReadOnlyGraphAggregate.commitº  rG  rD   c                 ó   — t          ¦   «         ‚rF   rF  rG   s    rC   rc   zReadOnlyGraphAggregate.rollback½  rG  rD   Fc                 óH   — | j         D ]}|                     | ||¦  «         Œd S rF   )r  re   )rA   r_   rf   r  s       rC   re   zReadOnlyGraphAggregate.openÀ  s6   € à”[ð 	4ð 	4ˆEØ�JŠJ�t˜]¨FÑ3Ô3Ð3Ð3ð	4ð 	4rD   c                 óB   — | j         D ]}|                     ¦   «          Œd S rF   )r  ri   )rA   r  s     rC   ri   zReadOnlyGraphAggregate.closeÅ  s,   € Ø”[ð 	ð 	ˆEØ�KŠK‰MŒMˆMˆMð	ð 	rD   c                 ó   — t          ¦   «         ‚rF   rF  r‡   s     rC   rs   zReadOnlyGraphAggregate.addÉ  rG  rD   c                 ó   — t          ¦   «         ‚rF   rF  r‚   s     rC   r�   zReadOnlyGraphAggregate.addNÌ  rG  rD   c                 ó   — t          ¦   «         ‚rF   rF  r‡   s     rC   r†   zReadOnlyGraphAggregate.removeÏ  rG  rD   c              #   óê   K  — |\  }}}| j         D ]b}t          |t          ¦  «        r%|                     | ||¦  «        D ]\  }}|||fV — ŒŒ<|                     |||f¦  «        D ]\  }}}|||fV — ŒŒcd S rF   )r  r:   r   r‰   rŠ   ©	rA   rj   ru   rv   rw   r  rð  rñ  rò  s	            rC   rŠ   zReadOnlyGraphAggregate.triplesÒ  sº   è è € Ø‰ˆˆ1ˆaØ”[ð 	%ð 	%ˆEÝ˜!�TÑ"Ô"ð %ØŸFšF 4¨¨AÑ.Ô.ð "ð "‘D�A�qØ˜Q ˜'�M�M�M�Mð"ð #(§-¢-°°A°q°	Ñ":Ô":ð %ð %‘J�B˜˜BØ˜b "˜*Ð$Ð$Ð$Ð$ð%ð	%ð 	%rD   c                 ó–   — d }t          |¦  «        dk    r|d         }| j        D ]#}|�|j        |j        k    r|d d…         |v r dS Œ$dS )NrÜ  rÛ  TF)rÿ   r  r2   )rA   rÕ  r…   r  s       rC   r£   z#ReadOnlyGraphAggregate.__contains__Ü  sk   € ØˆÝˆ~ÑÔ !Ò#Ð#Ø$ QÔ'ˆGØ”[ð 	 ð 	 ˆEØˆ %Ô"2°gÔ6HÒ"HÐ"HØ! " 1 "Ô%¨Ð.Ð.Ø˜4˜4øØˆurD   c              #   óx   K  — |\  }}}| j         D ])}|                     |||f¦  «        D ]\  }}}||||fV — ŒŒ*dS )z8Iterate over all the quads in the entire aggregate graphN)r  rŠ   rP  s	            rC   rx   zReadOnlyGraphAggregate.quadsæ  sp   è è € à‰ˆˆ1ˆaØ”[ð 	(ð 	(ˆEØ#Ÿmšm¨Q°°1¨IÑ6Ô6ð (ð (‘
��B˜Ø˜"˜b %Ð'Ð'Ð'Ð'Ð'ð(ð	(ð 	(rD   c                 ó>   — t          d„ | j        D ¦   «         ¦  «        S )Nc              3   ó4   K  — | ]}t          |¦  «        V — Œd S rF   )rÿ   rB  s     rC   r€   z1ReadOnlyGraphAggregate.__len__.<locals>.<genexpr>î  s(   è è € Ð/Ð/˜a•3�q‘6”6Ð/Ð/Ð/Ð/Ð/Ð/rD   )Úsumr  rG   s    rC   r�   zReadOnlyGraphAggregate.__len__í  s!   € ÝÐ/Ð/ 4¤;Ð/Ñ/Ô/Ñ/Ô/Ð/rD   c                 ó   — t          ¦   «         ‚rF   ©r,   rG   s    rC   r¦   zReadOnlyGraphAggregate.__hash__ð  ó   € Ý+Ñ-Ô-Ð-rD   c                 ó¨   — |€dS t          |t          ¦  «        rdS t          |t          ¦  «        r!| j        |j        k    | j        |j        k     z
  S dS )Nr¨   )r:   r&   r-   r  r«   s     rC   r­   zReadOnlyGraphAggregate.__cmp__ó  sX   € Øˆ=Ø�2Ý˜�uÑ%Ô%ð 	Ø�2Ý˜Õ5Ñ6Ô6ð 	Ø”K %¤,Ò.°4´;ÀÄÒ3MÑNÐNà�2rD   c                 ó   — t          ¦   «         ‚rF   rF  r«   s     rC   r»   zReadOnlyGraphAggregate.__iadd__ý  rG  rD   c                 ó   — t          ¦   «         ‚rF   rF  r«   s     rC   r½   zReadOnlyGraphAggregate.__isub__ 	  rG  rD   Nc              #   óz   K  — |\  }}}| j         D ]*}|                     |||f¦  «        }|D ]\  }}	}
||	|
fV — ŒŒ+d S rF   )r  rß   )rA   rj   r…   rÓ   rÔ   rÕ   r  Úchoicesru   rv   rw   s              rC   rß   z&ReadOnlyGraphAggregate.triples_choices	  sr   è è € Ø&,Ñ#ˆ�˜GØ”[ð 	ð 	ˆEØ×+Ò+¨W°iÀÐ,IÑJÔJˆGØ$ð ð ‘	��A�qØ˜˜A�g����ðð	ð 	rD   c                 ó€   — t          | d¦  «        r!| j        r| j                             |¦  «        S t          ¦   «         ‚©Nr3   )r=  r3   r  r,   r  s     rC   r  zReadOnlyGraphAggregate.qname	  sB   € Ý�4Ð,Ñ-Ô-ð 	5°$Ô2Hð 	5ØÔ)×/Ò/°Ñ4Ô4Ð4Ý+Ñ-Ô-Ð-rD   Tc                 ó‚   — t          | d¦  «        r"| j        r| j                             ||¦  «        S t          ¦   «         ‚r_  )r=  r3   r  r,   r  s      rC   r  z$ReadOnlyGraphAggregate.compute_qname	  sF   € Ý�4Ð,Ñ-Ô-ð 	G°$Ô2Hð 	GØÔ)×7Ò7¸¸XÑFÔFÐFÝ+Ñ-Ô-Ð-rD   c                 ó   — t          ¦   «         ‚rF   rW  )rA   rÄ   r   r!  s       rC   rÂ   zReadOnlyGraphAggregate.bind	  rX  rD   c              #   óÌ   K  — t          | d¦  «        r'| j                             ¦   «         D ]\  }}||fV — Œd S | j        D ]"}|                     ¦   «         D ]\  }}||fV — ŒŒ#d S r_  )r=  r3   rÁ   r  )rA   rÄ   r   r  s       rC   rÁ   z!ReadOnlyGraphAggregate.namespaces	  s°   è è € Ý�4Ð,Ñ-Ô-ð 	,Ø%)Ô%;×%FÒ%FÑ%HÔ%Hð (ð (Ñ!�˜	Ø˜iÐ'Ð'Ð'Ð'Ð'ð(ð (ð œð ,ð ,�Ø).×)9Ò)9Ñ);Ô);ð ,ð ,Ñ%�F˜IØ  )Ð+Ð+Ð+Ð+Ð+ð,ð,ð ,rD   r©   c                 ó   — t          ¦   «         ‚rF   rW  r&  s      rC   r%  z!ReadOnlyGraphAggregate.absolutize"	  rX  rD   c                 ó   — t          ¦   «         ‚rF   rF  )rA   r[  r\  r)  r-  s        rC   rb  zReadOnlyGraphAggregate.parse%	  rG  rD   c                 ó   — t          ¦   «         ‚rF   rW  rG   s    rC   rU   zReadOnlyGraphAggregate.n3(	  rX  rD   c                 ó   — t          ¦   «         ‚rF   rW  rG   s    rC   rƒ  z!ReadOnlyGraphAggregate.__reduce__+	  rX  rD   rà  r¸  rF   rº  r»  r¹  ) rV   r¾  r¿  rÀ  r8   rS   r]   ra   rc   re   ri   rs   r�   r†   rŠ   r£   rx   r�   r¦   r­   r»   r½   rß   r  r  rÂ   rÁ   r%  rb  rU   rƒ  rÊ  rË  s   @rC   r-   r-   Ÿ  sî  ø€ € € € € ðð ðð ð ð ð ð ðHð Hð Hð&ð &ð &ð&ð &ð &ð&ð &ð &ð4ð 4ð 4ð 4ð
ð ð ð&ð &ð &ð&ð &ð &ð&ð &ð &ð%ð %ð %ðð ð ð(ð (ð (ð0ð 0ð 0ð.ð .ð .ðð ð ð&ð &ð &ð&ð &ð &ð
ð ð ð ð.ð .ð .ð
.ð .ð .ð .ð
.ð .ð .ð .ð,ð ,ð ,ð.ð .ð .ð .ð&ð &ð &ð &ð.ð .ð .ð.ð .ð .ð .ð .ð .ð .rD   r-   c                  óV   — | D ]%}t          |t          ¦  «        sJ d|›d�¦   «         ‚Œ&dS )NzTerm rn   T)r:   r   )Útermsr™  s     rC   r|   r|   /	  sC   € Øð Lð LˆÝ˜!�TÑ"Ô"ÐKÐKÐKÈÈÈÐ$KÑKÔKÐKÐKØˆ4rD   c                   ó¬   — e Zd ZdZddededefd„Zd„ Zd	e	e
eeef         e
eeeef         f         d
d fd„Zdee
eeeef                  fd„Zd„ Zd„ ZdS )r.   a)  
    Wrapper around graph that turns batches of calls to Graph's add
    (and optionally, addN) into calls to batched calls to addN`.

    :Parameters:

      - graph: The graph to wrap
      - batch_size: The maximum number of triples to buffer before passing to
        Graph's addN
      - batch_addn: If True, then even calls to `addN` will be batched according to
        batch_size

    graph: The wrapped graph
    count: The number of triples buffered since initialization or the last call to reset
    batch: The current buffer of triples

    éè  Fr  Ú
batch_sizeÚ
batch_addnc                 ó–   — |r|dk     rt          d¦  «        ‚|| _        |f| _        || _        || _        |                      ¦   «          d S )Né   z$batch_size must be a positive number)r  r  Ú_BatchAddGraph__graph_tupleÚ_BatchAddGraph__batch_sizeÚ_BatchAddGraph__batch_addnÚreset)rA   r  rk  rl  s       rC   r8   zBatchAddGraph.__init__H	  sT   € Øð 	E˜Z¨!š^˜^ÝÐCÑDÔDÐDØˆŒ
Ø#˜XˆÔØ&ˆÔØ&ˆÔØ�
Š
‰ŒˆˆˆrD   c                 ó"   — g | _         d| _        | S )zQ
        Manually clear the buffered triples and reset the count to zero
        r   )ÚbatchÚcountrG   s    rC   rr  zBatchAddGraph.resetQ	  s   € ð ˆŒ
ØˆŒ
ØˆrD   rÕ  rÖ   c                 óL  — t          | j        ¦  «        | j        k    r&| j                             | j        ¦  «         g | _        | xj        dz  c_        t          |¦  «        dk    r#| j                             || j        z   ¦  «         n| j                             |¦  «         | S )zV
        Add a triple to the buffer

        :param triple: The triple to add
        r©   rÛ  )rÿ   rt  rp  r  r�   ru  r‹  ro  )rA   rÕ  s     rC   rs   zBatchAddGraph.addY	  s•   € õ ˆtŒz‰?Œ?˜dÔ/Ò/Ð/ØŒJ�OŠO˜DœJÑ'Ô'Ð'ØˆDŒJØˆ
Œ
�a‰ˆ
Œ
Ýˆ~ÑÔ !Ò#Ð#ØŒJ×Ò˜n¨tÔ/AÑAÑBÔBÐBÐBàŒJ×Ò˜nÑ-Ô-Ð-ØˆrD   rx   c                 ó~   — | j         r|D ]}|                      |¦  «         Œn| j                             |¦  «         | S rF   )rq  rs   r  r�   )rA   rx   Úqs      rC   r�   zBatchAddGraph.addNl	  sM   € ØÔð 	#Øð ð �Ø—’˜‘”��ðð ŒJ�OŠO˜EÑ"Ô"Ð"ØˆrD   c                 ó.   — |                       ¦   «          | S rF   )rr  rG   s    rC   Ú	__enter__zBatchAddGraph.__enter__t	  s   € Ø�
Š
‰ŒˆØˆrD   c                 óX   — |d         €!| j                              | j        ¦  «         d S d S ©Nr   )r  r�   rt  )rA   Úexcs     rC   Ú__exit__zBatchAddGraph.__exit__x	  s.   € ØˆqŒ6ˆ>ØŒJ�OŠO˜DœJÑ'Ô'Ð'Ð'Ð'ð ˆ>rD   N)rj  F)rV   r¾  r¿  rÀ  r&   r.  rÉ  r8   rr  r   r   r   r   rs   r   r�   rz  r~  rY   rD   rC   r.   r.   5	  sñ   € € € € € ðð ð$ð ˜eð °ð Èð ð ð ð ðð ð ðà˜e D¨$°Ð$4Ô5°u¸TÀ4ÈÈsÐ=RÔ7SÐSÔTðð 
ðð ð ð ð&˜( 5¨¨t°T¸3Ð)>Ô#?Ô@ð ð ð ð ðð ð ð(ð (ð (ð (ð (rD   r.   c                  ó6   — dd l } |                      ¦   «          d S r|  )ÚdoctestÚtestmod)r€  s    rC   Útestr‚  }	  s!   € Ø€N€N€Nà‡O‚OÑÔÐÐÐrD   Ú__main__)OÚtypingr   r   r   r   r   r   r	   r
   r   r   ÚloggingÚwarningsr   rˆ  Úrdflib.namespacer   r   r_  r   r   r   r   r  r   r   r   r   r   Úrdflib.pathsr   Úrdflib.storer   Úrdflib.serializerr   Úrdflib.parserr   r   r   Úrdflib.resourcer   Úrdflib.collectionr!   Úrdflib.utilÚrdflib.exceptionsr"   rD  rF  rB  r?  Úior#   Úurllib.parser$   Úurllib.requestr%   Ú	getLoggerrV   ÚloggerÚContextNoder  rÀ  Ú__all__r&   r'   r  r+   r(   ÚtermÚ	_ORDERINGrØ   r)   r  r*   r,   r-   r|   r.   r‚  rY   rD   rC   ú<module>r™     s“  ððð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð €€€Ø Ð Ð Ð Ð Ð Ø €€€Ø +Ð +Ð +Ð +Ð +Ð +Ð +Ð +Ø 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ø Ð Ð Ð Ø ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø (Ð (Ð (Ð (Ð (Ð (Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø -Ð -Ð -Ð -Ð -Ð -Ø $Ð $Ð $Ð $Ð $Ð $Ø (Ð (Ð (Ð (Ð (Ð (Ø Ð Ð Ð Ø )Ð )Ð )Ð )Ð )Ð )à 	€	€	€	Ø €€€Ø €€€Ø €€€à Ð Ð Ð Ð Ð Ø !Ð !Ð !Ð !Ð !Ð !Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'à€€€ØÐ Ð Ð à	ˆÔ	˜8Ñ	$Ô	$€ð �E˜6�MÔ"€Ø�D˜& $¨°Ô(=Ð=Ô>€ðt€ðn
ð 
ð 
€ðzð zð zð zð zˆDñ zô zð zðz'O?ð O?ð O?ð O?ð O?�uñ O?ô O?ð O?ðd "˜6Ð"8Ñ9Ô9Ð ðX4ð X4ð X4ð X4ð X4Ðñ X4ô X4ð X4ðv/:ð /:ð /:ð /:ð /:�%ñ /:ô /:ð /:ðl &(€„Ô �kÑ "ð/ð /ð /ð /ð /ˆ&ñ /ô /ð /ðd
ð 
ð 
ð 
ð 
˜Iñ 
ô 
ð 
ðXð Xð Xð Xð X Iñ Xô Xð XðM.ð M.ð M.ð M.ð M.Ð-ñ M.ô M.ð M.ð`ð ð ðE(ð E(ð E(ð E(ð E(�Fñ E(ô E(ð E(ðPð ð ð ˆzÒÐØ€D�F„F€F€F€Fð ÐrD   