Upgrades pyo3 to 0.14

pull/93/head
Tpt 3 years ago
parent a58a6fac8e
commit 35ecc12557
  1. 4
      python/src/io.rs
  2. 24
      python/src/memory_store.rs
  3. 12
      python/src/model.rs
  4. 24
      python/src/sled_store.rs

@ -46,7 +46,7 @@ pub fn add_to_module(module: &PyModule) -> PyResult<()> {
/// >>> list(parse(input, "text/turtle", base_iri="http://example.com/")) /// >>> list(parse(input, "text/turtle", base_iri="http://example.com/"))
/// [<Triple subject=<NamedNode value=http://example.com/foo> predicate=<NamedNode value=http://example.com/p> object=<Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>>>] /// [<Triple subject=<NamedNode value=http://example.com/foo> predicate=<NamedNode value=http://example.com/p> object=<Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>>>]
#[pyfunction] #[pyfunction]
#[text_signature = "(input, /, mime_type, *, base_iri = None)"] #[pyo3(text_signature = "(input, /, mime_type, *, base_iri = None)")]
pub fn parse( pub fn parse(
input: PyObject, input: PyObject,
mime_type: &str, mime_type: &str,
@ -112,7 +112,7 @@ pub fn parse(
/// >>> output.getvalue() /// >>> output.getvalue()
/// b'<http://example.com> <http://example.com/p> "1" .\n' /// b'<http://example.com> <http://example.com/p> "1" .\n'
#[pyfunction] #[pyfunction]
#[text_signature = "(input, output, /, mime_type, *, base_iri = None)"] #[pyo3(text_signature = "(input, output, /, mime_type, *, base_iri = None)")]
pub fn serialize(input: &PyAny, output: PyObject, mime_type: &str) -> PyResult<()> { pub fn serialize(input: &PyAny, output: PyObject, mime_type: &str) -> PyResult<()> {
let output = PyFileLike::new(output); let output = PyFileLike::new(output);
if let Some(graph_format) = GraphFormat::from_media_type(mime_type) { if let Some(graph_format) = GraphFormat::from_media_type(mime_type) {

@ -25,7 +25,7 @@ use std::io::BufReader;
/// '<http://example.com> <http://example.com/p> "1" <http://example.com/g> .\n' /// '<http://example.com> <http://example.com/p> "1" <http://example.com/g> .\n'
#[pyclass(name = "MemoryStore", module = "oxigraph")] #[pyclass(name = "MemoryStore", module = "oxigraph")]
#[derive(Eq, PartialEq, Clone)] #[derive(Eq, PartialEq, Clone)]
#[text_signature = "()"] #[pyo3(text_signature = "()")]
pub struct PyMemoryStore { pub struct PyMemoryStore {
inner: MemoryStore, inner: MemoryStore,
} }
@ -48,7 +48,7 @@ impl PyMemoryStore {
/// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g'))) /// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g')))
/// >>> list(store) /// >>> list(store)
/// [<Quad subject=<NamedNode value=http://example.com> predicate=<NamedNode value=http://example.com/p> object=<Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>> graph_name=<NamedNode value=http://example.com/g>>] /// [<Quad subject=<NamedNode value=http://example.com> predicate=<NamedNode value=http://example.com/p> object=<Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>> graph_name=<NamedNode value=http://example.com/g>>]
#[text_signature = "($self, quad)"] #[pyo3(text_signature = "($self, quad)")]
fn add(&self, quad: PyQuad) { fn add(&self, quad: PyQuad) {
self.inner.insert(quad) self.inner.insert(quad)
} }
@ -64,7 +64,7 @@ impl PyMemoryStore {
/// >>> store.remove(quad) /// >>> store.remove(quad)
/// >>> list(store) /// >>> list(store)
/// [] /// []
#[text_signature = "($self, quad)"] #[pyo3(text_signature = "($self, quad)")]
fn remove(&self, quad: &PyQuad) { fn remove(&self, quad: &PyQuad) {
self.inner.remove(quad) self.inner.remove(quad)
} }
@ -86,7 +86,7 @@ impl PyMemoryStore {
/// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g'))) /// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g')))
/// >>> list(store.quads_for_pattern(NamedNode('http://example.com'), None, None, None)) /// >>> list(store.quads_for_pattern(NamedNode('http://example.com'), None, None, None))
/// [<Quad subject=<NamedNode value=http://example.com> predicate=<NamedNode value=http://example.com/p> object=<Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>> graph_name=<NamedNode value=http://example.com/g>>] /// [<Quad subject=<NamedNode value=http://example.com> predicate=<NamedNode value=http://example.com/p> object=<Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>> graph_name=<NamedNode value=http://example.com/g>>]
#[text_signature = "($self, subject, predicate, object, graph_name = None)"] #[pyo3(text_signature = "($self, subject, predicate, object, graph_name = None)")]
fn quads_for_pattern( fn quads_for_pattern(
&self, &self,
subject: &PyAny, subject: &PyAny,
@ -140,7 +140,9 @@ impl PyMemoryStore {
/// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'))) /// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1')))
/// >>> store.query('ASK { ?s ?p ?o }') /// >>> store.query('ASK { ?s ?p ?o }')
/// True /// True
#[text_signature = "($self, query, *, use_default_graph_as_union, default_graph, named_graphs)"] #[pyo3(
text_signature = "($self, query, *, use_default_graph_as_union, default_graph, named_graphs)"
)]
#[args( #[args(
query, query,
"*", "*",
@ -197,7 +199,7 @@ impl PyMemoryStore {
/// >>> store.update('DELETE WHERE { <http://example.com> ?p ?o }') /// >>> store.update('DELETE WHERE { <http://example.com> ?p ?o }')
/// >>> list(store) /// >>> list(store)
/// [] /// []
#[text_signature = "($self, update)"] #[pyo3(text_signature = "($self, update)")]
fn update(&self, update: &str) -> PyResult<()> { fn update(&self, update: &str) -> PyResult<()> {
self.inner.update(update).map_err(map_evaluation_error) self.inner.update(update).map_err(map_evaluation_error)
} }
@ -231,7 +233,7 @@ impl PyMemoryStore {
/// >>> store.load(io.BytesIO(b'<foo> <p> "1" .'), "text/turtle", base_iri="http://example.com/", to_graph=NamedNode("http://example.com/g")) /// >>> store.load(io.BytesIO(b'<foo> <p> "1" .'), "text/turtle", base_iri="http://example.com/", to_graph=NamedNode("http://example.com/g"))
/// >>> list(store) /// >>> list(store)
/// [<Quad subject=<NamedNode value=http://example.com/foo> predicate=<NamedNode value=http://example.com/p> object=<Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>> graph_name=<NamedNode value=http://example.com/g>>] /// [<Quad subject=<NamedNode value=http://example.com/foo> predicate=<NamedNode value=http://example.com/p> object=<Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>> graph_name=<NamedNode value=http://example.com/g>>]
#[text_signature = "($self, input, /, mime_type, *, base_iri = None, to_graph = None)"] #[pyo3(text_signature = "($self, input, /, mime_type, *, base_iri = None, to_graph = None)")]
#[args(input, mime_type, "*", base_iri = "None", to_graph = "None")] #[args(input, mime_type, "*", base_iri = "None", to_graph = "None")]
fn load( fn load(
&self, &self,
@ -300,7 +302,7 @@ impl PyMemoryStore {
/// >>> store.dump(output, "text/turtle", from_graph=NamedNode("http://example.com/g")) /// >>> store.dump(output, "text/turtle", from_graph=NamedNode("http://example.com/g"))
/// >>> output.getvalue() /// >>> output.getvalue()
/// b'<http://example.com> <http://example.com/p> "1" .\n' /// b'<http://example.com> <http://example.com/p> "1" .\n'
#[text_signature = "($self, output, /, mime_type, *, from_graph = None)"] #[pyo3(text_signature = "($self, output, /, mime_type, *, from_graph = None)")]
#[args(output, mime_type, "*", from_graph = "None")] #[args(output, mime_type, "*", from_graph = "None")]
fn dump(&self, output: PyObject, mime_type: &str, from_graph: Option<&PyAny>) -> PyResult<()> { fn dump(&self, output: PyObject, mime_type: &str, from_graph: Option<&PyAny>) -> PyResult<()> {
let from_graph_name = if let Some(graph_name) = from_graph { let from_graph_name = if let Some(graph_name) = from_graph {
@ -343,7 +345,7 @@ impl PyMemoryStore {
/// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g'))) /// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g')))
/// >>> list(store.named_graphs()) /// >>> list(store.named_graphs())
/// [<NamedNode value=http://example.com/g>] /// [<NamedNode value=http://example.com/g>]
#[text_signature = "($self)"] #[pyo3(text_signature = "($self)")]
fn named_graphs(&self) -> GraphNameIter { fn named_graphs(&self) -> GraphNameIter {
GraphNameIter { GraphNameIter {
inner: self.inner.named_graphs(), inner: self.inner.named_graphs(),
@ -359,7 +361,7 @@ impl PyMemoryStore {
/// >>> store.add_graph(NamedNode('http://example.com/g')) /// >>> store.add_graph(NamedNode('http://example.com/g'))
/// >>> list(store.named_graphs()) /// >>> list(store.named_graphs())
/// [<NamedNode value=http://example.com/g>] /// [<NamedNode value=http://example.com/g>]
#[text_signature = "($self, graph_name)"] #[pyo3(text_signature = "($self, graph_name)")]
fn add_graph(&self, graph_name: PyGraphName) { fn add_graph(&self, graph_name: PyGraphName) {
match graph_name { match graph_name {
PyGraphName::DefaultGraph(_) => (), PyGraphName::DefaultGraph(_) => (),
@ -380,7 +382,7 @@ impl PyMemoryStore {
/// >>> store.remove_graph(NamedNode('http://example.com/g')) /// >>> store.remove_graph(NamedNode('http://example.com/g'))
/// >>> list(store) /// >>> list(store)
/// [] /// []
#[text_signature = "($self, graph_name)"] #[pyo3(text_signature = "($self, graph_name)")]
fn remove_graph(&self, graph_name: &PyAny) -> PyResult<()> { fn remove_graph(&self, graph_name: &PyAny) -> PyResult<()> {
match PyGraphNameRef::try_from(graph_name)? { match PyGraphNameRef::try_from(graph_name)? {
PyGraphNameRef::DefaultGraph => self.inner.clear_graph(GraphNameRef::DefaultGraph), PyGraphNameRef::DefaultGraph => self.inner.clear_graph(GraphNameRef::DefaultGraph),

@ -21,7 +21,7 @@ use std::vec::IntoIter;
/// >>> str(NamedNode('http://example.com')) /// >>> str(NamedNode('http://example.com'))
/// '<http://example.com>' /// '<http://example.com>'
#[pyclass(name = "NamedNode", module = "oxigraph")] #[pyclass(name = "NamedNode", module = "oxigraph")]
#[text_signature = "(value)"] #[pyo3(text_signature = "(value)")]
#[derive(Eq, PartialEq, Ord, PartialOrd, Debug, Clone, Hash)] #[derive(Eq, PartialEq, Ord, PartialOrd, Debug, Clone, Hash)]
pub struct PyNamedNode { pub struct PyNamedNode {
inner: NamedNode, inner: NamedNode,
@ -120,7 +120,7 @@ impl PyObjectProtocol for PyNamedNode {
/// >>> str(BlankNode('ex')) /// >>> str(BlankNode('ex'))
/// '_:ex' /// '_:ex'
#[pyclass(name = "BlankNode", module = "oxigraph")] #[pyclass(name = "BlankNode", module = "oxigraph")]
#[text_signature = "(value)"] #[pyo3(text_signature = "(value)")]
#[derive(Eq, PartialEq, Debug, Clone, Hash)] #[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub struct PyBlankNode { pub struct PyBlankNode {
inner: BlankNode, inner: BlankNode,
@ -230,7 +230,7 @@ impl PyObjectProtocol for PyBlankNode {
/// >>> str(Literal('11', datatype=NamedNode('http://www.w3.org/2001/XMLSchema#integer'))) /// >>> str(Literal('11', datatype=NamedNode('http://www.w3.org/2001/XMLSchema#integer')))
/// '"11"^^<http://www.w3.org/2001/XMLSchema#integer>' /// '"11"^^<http://www.w3.org/2001/XMLSchema#integer>'
#[pyclass(name = "Literal", module = "oxigraph")] #[pyclass(name = "Literal", module = "oxigraph")]
#[text_signature = "(value, *, datatype = None, language = None)"] #[pyo3(text_signature = "(value, *, datatype = None, language = None)")]
#[derive(Eq, PartialEq, Debug, Clone, Hash)] #[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub struct PyLiteral { pub struct PyLiteral {
inner: Literal, inner: Literal,
@ -493,7 +493,7 @@ impl IntoPy<PyObject> for PyTerm {
/// >>> (s, p, o) = Triple(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1')) /// >>> (s, p, o) = Triple(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'))
#[pyclass(name = "Triple", module = "oxigraph")] #[pyclass(name = "Triple", module = "oxigraph")]
#[derive(Eq, PartialEq, Debug, Clone, Hash)] #[derive(Eq, PartialEq, Debug, Clone, Hash)]
#[text_signature = "(subject, predicate, object)"] #[pyo3(text_signature = "(subject, predicate, object)")]
pub struct PyTriple { pub struct PyTriple {
inner: Triple, inner: Triple,
} }
@ -672,7 +672,7 @@ impl IntoPy<PyObject> for PyGraphName {
/// ///
/// >>> (s, p, o, g) = Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g')) /// >>> (s, p, o, g) = Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g'))
#[pyclass(name = "Quad", module = "oxigraph")] #[pyclass(name = "Quad", module = "oxigraph")]
#[text_signature = "(subject, predicate, object, graph_name = None)"] #[pyo3(text_signature = "(subject, predicate, object, graph_name = None)")]
#[derive(Eq, PartialEq, Debug, Clone, Hash)] #[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub struct PyQuad { pub struct PyQuad {
inner: Quad, inner: Quad,
@ -843,7 +843,7 @@ impl PyIterProtocol for PyQuad {
/// >>> str(Variable('foo')) /// >>> str(Variable('foo'))
/// '?foo' /// '?foo'
#[pyclass(name = "Variable", module = "oxigraph")] #[pyclass(name = "Variable", module = "oxigraph")]
#[text_signature = "(value)"] #[pyo3(text_signature = "(value)")]
#[derive(Eq, PartialEq, Debug, Clone, Hash)] #[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub struct PyVariable { pub struct PyVariable {
inner: Variable, inner: Variable,

@ -31,7 +31,7 @@ use std::io::BufReader;
/// >>> str(store) /// >>> str(store)
/// '<http://example.com> <http://example.com/p> "1" <http://example.com/g> .\n' /// '<http://example.com> <http://example.com/p> "1" <http://example.com/g> .\n'
#[pyclass(name = "SledStore", module = "oxigraph")] #[pyclass(name = "SledStore", module = "oxigraph")]
#[text_signature = "(path = None)"] #[pyo3(text_signature = "(path = None)")]
#[derive(Clone)] #[derive(Clone)]
pub struct PySledStore { pub struct PySledStore {
inner: SledStore, inner: SledStore,
@ -61,7 +61,7 @@ impl PySledStore {
/// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g'))) /// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g')))
/// >>> list(store) /// >>> list(store)
/// [<Quad subject=<NamedNode value=http://example.com> predicate=<NamedNode value=http://example.com/p> object=<Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>> graph_name=<NamedNode value=http://example.com/g>>] /// [<Quad subject=<NamedNode value=http://example.com> predicate=<NamedNode value=http://example.com/p> object=<Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>> graph_name=<NamedNode value=http://example.com/g>>]
#[text_signature = "($self, quad)"] #[pyo3(text_signature = "($self, quad)")]
fn add(&self, quad: &PyQuad) -> PyResult<()> { fn add(&self, quad: &PyQuad) -> PyResult<()> {
self.inner.insert(quad).map_err(map_io_err) self.inner.insert(quad).map_err(map_io_err)
} }
@ -78,7 +78,7 @@ impl PySledStore {
/// >>> store.remove(quad) /// >>> store.remove(quad)
/// >>> list(store) /// >>> list(store)
/// [] /// []
#[text_signature = "($self, quad)"] #[pyo3(text_signature = "($self, quad)")]
fn remove(&self, quad: &PyQuad) -> PyResult<()> { fn remove(&self, quad: &PyQuad) -> PyResult<()> {
self.inner.remove(quad).map_err(map_io_err) self.inner.remove(quad).map_err(map_io_err)
} }
@ -101,7 +101,7 @@ impl PySledStore {
/// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g'))) /// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g')))
/// >>> list(store.quads_for_pattern(NamedNode('http://example.com'), None, None, None)) /// >>> list(store.quads_for_pattern(NamedNode('http://example.com'), None, None, None))
/// [<Quad subject=<NamedNode value=http://example.com> predicate=<NamedNode value=http://example.com/p> object=<Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>> graph_name=<NamedNode value=http://example.com/g>>] /// [<Quad subject=<NamedNode value=http://example.com> predicate=<NamedNode value=http://example.com/p> object=<Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>> graph_name=<NamedNode value=http://example.com/g>>]
#[text_signature = "($self, subject, predicate, object, graph_name = None)"] #[pyo3(text_signature = "($self, subject, predicate, object, graph_name = None)")]
fn quads_for_pattern( fn quads_for_pattern(
&self, &self,
subject: &PyAny, subject: &PyAny,
@ -156,7 +156,9 @@ impl PySledStore {
/// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'))) /// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1')))
/// >>> store.query('ASK { ?s ?p ?o }') /// >>> store.query('ASK { ?s ?p ?o }')
/// True /// True
#[text_signature = "($self, query, *, use_default_graph_as_union, default_graph, named_graphs)"] #[pyo3(
text_signature = "($self, query, *, use_default_graph_as_union, default_graph, named_graphs)"
)]
#[args( #[args(
query, query,
"*", "*",
@ -214,7 +216,7 @@ impl PySledStore {
/// >>> store.update('DELETE WHERE { <http://example.com> ?p ?o }') /// >>> store.update('DELETE WHERE { <http://example.com> ?p ?o }')
/// >>> list(store) /// >>> list(store)
/// [] /// []
#[text_signature = "($self, update)"] #[pyo3(text_signature = "($self, update)")]
fn update(&self, update: &str) -> PyResult<()> { fn update(&self, update: &str) -> PyResult<()> {
self.inner.update(update).map_err(map_evaluation_error) self.inner.update(update).map_err(map_evaluation_error)
} }
@ -249,7 +251,7 @@ impl PySledStore {
/// >>> store.load(io.BytesIO(b'<foo> <p> "1" .'), "text/turtle", base_iri="http://example.com/", to_graph=NamedNode("http://example.com/g")) /// >>> store.load(io.BytesIO(b'<foo> <p> "1" .'), "text/turtle", base_iri="http://example.com/", to_graph=NamedNode("http://example.com/g"))
/// >>> list(store) /// >>> list(store)
/// [<Quad subject=<NamedNode value=http://example.com/foo> predicate=<NamedNode value=http://example.com/p> object=<Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>> graph_name=<NamedNode value=http://example.com/g>>] /// [<Quad subject=<NamedNode value=http://example.com/foo> predicate=<NamedNode value=http://example.com/p> object=<Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>> graph_name=<NamedNode value=http://example.com/g>>]
#[text_signature = "($self, data, /, mime_type, *, base_iri = None, to_graph = None)"] #[pyo3(text_signature = "($self, data, /, mime_type, *, base_iri = None, to_graph = None)")]
#[args(input, mime_type, "*", base_iri = "None", to_graph = "None")] #[args(input, mime_type, "*", base_iri = "None", to_graph = "None")]
fn load( fn load(
&self, &self,
@ -319,7 +321,7 @@ impl PySledStore {
/// >>> store.dump(output, "text/turtle", from_graph=NamedNode("http://example.com/g")) /// >>> store.dump(output, "text/turtle", from_graph=NamedNode("http://example.com/g"))
/// >>> output.getvalue() /// >>> output.getvalue()
/// b'<http://example.com> <http://example.com/p> "1" .\n' /// b'<http://example.com> <http://example.com/p> "1" .\n'
#[text_signature = "($self, output, /, mime_type, *, from_graph = None)"] #[pyo3(text_signature = "($self, output, /, mime_type, *, from_graph = None)")]
#[args(output, mime_type, "*", from_graph = "None")] #[args(output, mime_type, "*", from_graph = "None")]
fn dump(&self, output: PyObject, mime_type: &str, from_graph: Option<&PyAny>) -> PyResult<()> { fn dump(&self, output: PyObject, mime_type: &str, from_graph: Option<&PyAny>) -> PyResult<()> {
let from_graph_name = if let Some(graph_name) = from_graph { let from_graph_name = if let Some(graph_name) = from_graph {
@ -363,7 +365,7 @@ impl PySledStore {
/// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g'))) /// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g')))
/// >>> list(store.named_graphs()) /// >>> list(store.named_graphs())
/// [<NamedNode value=http://example.com/g>] /// [<NamedNode value=http://example.com/g>]
#[text_signature = "($self)"] #[pyo3(text_signature = "($self)")]
fn named_graphs(&self) -> GraphNameIter { fn named_graphs(&self) -> GraphNameIter {
GraphNameIter { GraphNameIter {
inner: self.inner.named_graphs(), inner: self.inner.named_graphs(),
@ -380,7 +382,7 @@ impl PySledStore {
/// >>> store.add_graph(NamedNode('http://example.com/g')) /// >>> store.add_graph(NamedNode('http://example.com/g'))
/// >>> list(store.named_graphs()) /// >>> list(store.named_graphs())
/// [<NamedNode value=http://example.com/g>] /// [<NamedNode value=http://example.com/g>]
#[text_signature = "($self, graph_name)"] #[pyo3(text_signature = "($self, graph_name)")]
fn add_graph(&self, graph_name: &PyAny) -> PyResult<()> { fn add_graph(&self, graph_name: &PyAny) -> PyResult<()> {
match PyGraphNameRef::try_from(graph_name)? { match PyGraphNameRef::try_from(graph_name)? {
PyGraphNameRef::DefaultGraph => Ok(()), PyGraphNameRef::DefaultGraph => Ok(()),
@ -407,7 +409,7 @@ impl PySledStore {
/// >>> store.remove_graph(NamedNode('http://example.com/g')) /// >>> store.remove_graph(NamedNode('http://example.com/g'))
/// >>> list(store) /// >>> list(store)
/// [] /// []
#[text_signature = "($self, graph_name)"] #[pyo3(text_signature = "($self, graph_name)")]
fn remove_graph(&self, graph_name: &PyAny) -> PyResult<()> { fn remove_graph(&self, graph_name: &PyAny) -> PyResult<()> {
match PyGraphNameRef::try_from(graph_name)? { match PyGraphNameRef::try_from(graph_name)? {
PyGraphNameRef::DefaultGraph => self.inner.clear_graph(GraphNameRef::DefaultGraph), PyGraphNameRef::DefaultGraph => self.inner.clear_graph(GraphNameRef::DefaultGraph),

Loading…
Cancel
Save