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/"))
/// [<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]
#[text_signature = "(input, /, mime_type, *, base_iri = None)"]
#[pyo3(text_signature = "(input, /, mime_type, *, base_iri = None)")]
pub fn parse(
input: PyObject,
mime_type: &str,
@ -112,7 +112,7 @@ pub fn parse(
/// >>> output.getvalue()
/// b'<http://example.com> <http://example.com/p> "1" .\n'
#[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<()> {
let output = PyFileLike::new(output);
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'
#[pyclass(name = "MemoryStore", module = "oxigraph")]
#[derive(Eq, PartialEq, Clone)]
#[text_signature = "()"]
#[pyo3(text_signature = "()")]
pub struct PyMemoryStore {
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')))
/// >>> 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>>]
#[text_signature = "($self, quad)"]
#[pyo3(text_signature = "($self, quad)")]
fn add(&self, quad: PyQuad) {
self.inner.insert(quad)
}
@ -64,7 +64,7 @@ impl PyMemoryStore {
/// >>> store.remove(quad)
/// >>> list(store)
/// []
#[text_signature = "($self, quad)"]
#[pyo3(text_signature = "($self, quad)")]
fn remove(&self, quad: &PyQuad) {
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')))
/// >>> 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>>]
#[text_signature = "($self, subject, predicate, object, graph_name = None)"]
#[pyo3(text_signature = "($self, subject, predicate, object, graph_name = None)")]
fn quads_for_pattern(
&self,
subject: &PyAny,
@ -140,7 +140,9 @@ impl PyMemoryStore {
/// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1')))
/// >>> store.query('ASK { ?s ?p ?o }')
/// 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(
query,
"*",
@ -197,7 +199,7 @@ impl PyMemoryStore {
/// >>> store.update('DELETE WHERE { <http://example.com> ?p ?o }')
/// >>> list(store)
/// []
#[text_signature = "($self, update)"]
#[pyo3(text_signature = "($self, update)")]
fn update(&self, update: &str) -> PyResult<()> {
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"))
/// >>> 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>>]
#[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")]
fn load(
&self,
@ -300,7 +302,7 @@ impl PyMemoryStore {
/// >>> store.dump(output, "text/turtle", from_graph=NamedNode("http://example.com/g"))
/// >>> output.getvalue()
/// 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")]
fn dump(&self, output: PyObject, mime_type: &str, from_graph: Option<&PyAny>) -> PyResult<()> {
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')))
/// >>> list(store.named_graphs())
/// [<NamedNode value=http://example.com/g>]
#[text_signature = "($self)"]
#[pyo3(text_signature = "($self)")]
fn named_graphs(&self) -> GraphNameIter {
GraphNameIter {
inner: self.inner.named_graphs(),
@ -359,7 +361,7 @@ impl PyMemoryStore {
/// >>> store.add_graph(NamedNode('http://example.com/g'))
/// >>> list(store.named_graphs())
/// [<NamedNode value=http://example.com/g>]
#[text_signature = "($self, graph_name)"]
#[pyo3(text_signature = "($self, graph_name)")]
fn add_graph(&self, graph_name: PyGraphName) {
match graph_name {
PyGraphName::DefaultGraph(_) => (),
@ -380,7 +382,7 @@ impl PyMemoryStore {
/// >>> store.remove_graph(NamedNode('http://example.com/g'))
/// >>> list(store)
/// []
#[text_signature = "($self, graph_name)"]
#[pyo3(text_signature = "($self, graph_name)")]
fn remove_graph(&self, graph_name: &PyAny) -> PyResult<()> {
match PyGraphNameRef::try_from(graph_name)? {
PyGraphNameRef::DefaultGraph => self.inner.clear_graph(GraphNameRef::DefaultGraph),

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

@ -31,7 +31,7 @@ use std::io::BufReader;
/// >>> str(store)
/// '<http://example.com> <http://example.com/p> "1" <http://example.com/g> .\n'
#[pyclass(name = "SledStore", module = "oxigraph")]
#[text_signature = "(path = None)"]
#[pyo3(text_signature = "(path = None)")]
#[derive(Clone)]
pub struct PySledStore {
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')))
/// >>> 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>>]
#[text_signature = "($self, quad)"]
#[pyo3(text_signature = "($self, quad)")]
fn add(&self, quad: &PyQuad) -> PyResult<()> {
self.inner.insert(quad).map_err(map_io_err)
}
@ -78,7 +78,7 @@ impl PySledStore {
/// >>> store.remove(quad)
/// >>> list(store)
/// []
#[text_signature = "($self, quad)"]
#[pyo3(text_signature = "($self, quad)")]
fn remove(&self, quad: &PyQuad) -> PyResult<()> {
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')))
/// >>> 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>>]
#[text_signature = "($self, subject, predicate, object, graph_name = None)"]
#[pyo3(text_signature = "($self, subject, predicate, object, graph_name = None)")]
fn quads_for_pattern(
&self,
subject: &PyAny,
@ -156,7 +156,9 @@ impl PySledStore {
/// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1')))
/// >>> store.query('ASK { ?s ?p ?o }')
/// 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(
query,
"*",
@ -214,7 +216,7 @@ impl PySledStore {
/// >>> store.update('DELETE WHERE { <http://example.com> ?p ?o }')
/// >>> list(store)
/// []
#[text_signature = "($self, update)"]
#[pyo3(text_signature = "($self, update)")]
fn update(&self, update: &str) -> PyResult<()> {
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"))
/// >>> 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>>]
#[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")]
fn load(
&self,
@ -319,7 +321,7 @@ impl PySledStore {
/// >>> store.dump(output, "text/turtle", from_graph=NamedNode("http://example.com/g"))
/// >>> output.getvalue()
/// 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")]
fn dump(&self, output: PyObject, mime_type: &str, from_graph: Option<&PyAny>) -> PyResult<()> {
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')))
/// >>> list(store.named_graphs())
/// [<NamedNode value=http://example.com/g>]
#[text_signature = "($self)"]
#[pyo3(text_signature = "($self)")]
fn named_graphs(&self) -> GraphNameIter {
GraphNameIter {
inner: self.inner.named_graphs(),
@ -380,7 +382,7 @@ impl PySledStore {
/// >>> store.add_graph(NamedNode('http://example.com/g'))
/// >>> list(store.named_graphs())
/// [<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<()> {
match PyGraphNameRef::try_from(graph_name)? {
PyGraphNameRef::DefaultGraph => Ok(()),
@ -407,7 +409,7 @@ impl PySledStore {
/// >>> store.remove_graph(NamedNode('http://example.com/g'))
/// >>> list(store)
/// []
#[text_signature = "($self, graph_name)"]
#[pyo3(text_signature = "($self, graph_name)")]
fn remove_graph(&self, graph_name: &PyAny) -> PyResult<()> {
match PyGraphNameRef::try_from(graph_name)? {
PyGraphNameRef::DefaultGraph => self.inner.clear_graph(GraphNameRef::DefaultGraph),

Loading…
Cancel
Save