Upgrades pyo3 to 0.14

pull/171/head
Tpt 3 years ago
parent 18e1e03f0f
commit ca92b8da7d
  1. 2
      python/Cargo.toml
  2. 4
      python/src/io.rs
  3. 12
      python/src/model.rs
  4. 24
      python/src/store.rs

@ -17,7 +17,7 @@ doctest = false
[dependencies]
oxigraph = {version = "0.3.0-dev", path="../lib", features = ["http_client"]}
pyo3 = {version = "0.13", features = ["extension-module", "abi3-py36"]}
pyo3 = {version = "0.14", features = ["extension-module", "abi3-py36"]}
native-tls = {version = "0.2", features = ["vendored"]}
[package.metadata.maturin]

@ -45,7 +45,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,
@ -111,7 +111,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) {

@ -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,
@ -126,7 +126,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,
@ -242,7 +242,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,
@ -546,7 +546,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,
}
@ -731,7 +731,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,
@ -902,7 +902,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,

@ -28,7 +28,7 @@ use std::io::BufReader;
/// >>> str(store)
/// '<http://example.com> <http://example.com/p> "1" <http://example.com/g> .\n'
#[pyclass(name = "Store", module = "oxigraph")]
#[text_signature = "(path = None)"]
#[pyo3(text_signature = "(path = None)")]
#[derive(Clone)]
pub struct PyStore {
inner: Store,
@ -58,7 +58,7 @@ impl PyStore {
/// >>> 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)?;
Ok(())
@ -76,7 +76,7 @@ impl PyStore {
/// >>> 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)?;
Ok(())
@ -100,7 +100,7 @@ impl PyStore {
/// >>> 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,
@ -155,7 +155,9 @@ impl PyStore {
/// >>> 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,
"*",
@ -213,7 +215,7 @@ impl PyStore {
/// >>> 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)
}
@ -248,7 +250,7 @@ impl PyStore {
/// >>> 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,
@ -318,7 +320,7 @@ impl PyStore {
/// >>> 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 {
@ -362,7 +364,7 @@ impl PyStore {
/// >>> 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(),
@ -379,7 +381,7 @@ impl PyStore {
/// >>> 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(()),
@ -408,7 +410,7 @@ impl PyStore {
/// >>> 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