Upgrades pyo3 to 0.13

Drops python 3.5 support
pull/71/head
Tpt 4 years ago
parent d9fadca612
commit 40a08ac623
  1. 2
      python/Cargo.toml
  2. 4
      python/src/io.rs
  3. 4
      python/src/memory_store.rs
  4. 50
      python/src/model.rs
  5. 4
      python/src/sled_store.rs
  6. 10
      python/src/sparql.rs

@ -16,7 +16,7 @@ doctest = false
[dependencies]
oxigraph = {version = "0.1.1", path="../lib", features = ["sled", "http_client"]}
pyo3 = {version = "0.12", features = ["extension-module"]}
pyo3 = {version = "0.13", features = ["extension-module"]}
[package.metadata.maturin]
classifier = [

@ -145,7 +145,7 @@ pub fn serialize(input: &PyAny, output: &PyAny, mime_type: &str, py: Python<'_>)
}
}
#[pyclass(name = TripleReader)]
#[pyclass(name = "TripleReader", module = "oxigraph")]
pub struct PyTripleReader {
inner: TripleReader<BufReader<PyFileLike>>,
}
@ -164,7 +164,7 @@ impl PyIterProtocol for PyTripleReader {
}
}
#[pyclass(name = QuadReader)]
#[pyclass(name = "QuadReader", module = "oxigraph")]
pub struct PyQuadReader {
inner: QuadReader<BufReader<PyFileLike>>,
}

@ -24,7 +24,7 @@ use std::io::BufReader;
/// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g')))
/// >>> str(store)
/// '<http://example.com> <http://example.com/p> "1" <http://example.com/g> .\n'
#[pyclass(name = MemoryStore)]
#[pyclass(name = "MemoryStore", module = "oxigraph")]
#[derive(Eq, PartialEq, Clone)]
#[text_signature = "()"]
pub struct PyMemoryStore {
@ -385,7 +385,7 @@ impl PyIterProtocol for PyMemoryStore {
}
}
#[pyclass(unsendable)]
#[pyclass(unsendable, module = "oxigraph")]
pub struct QuadIter {
inner: MemoryQuadIter,
}

@ -20,7 +20,7 @@ use std::vec::IntoIter;
///
/// >>> str(NamedNode('http://example.com'))
/// '<http://example.com>'
#[pyclass(name = NamedNode)]
#[pyclass(name = "NamedNode", module = "oxigraph")]
#[text_signature = "(value)"]
#[derive(Eq, PartialEq, Ord, PartialOrd, Debug, Clone, Hash)]
pub struct PyNamedNode {
@ -96,9 +96,9 @@ impl PyObjectProtocol for PyNamedNode {
fn __richcmp__(&self, other: &PyAny, op: CompareOp) -> PyResult<bool> {
if let Ok(other) = other.downcast::<PyCell<PyNamedNode>>() {
Ok(eq_ord_compare(self, &other.borrow(), op))
} else if PyBlankNode::is_instance(other)
|| PyLiteral::is_instance(other)
|| PyDefaultGraph::is_instance(other)
} else if PyBlankNode::is_type_of(other)
|| PyLiteral::is_type_of(other)
|| PyDefaultGraph::is_type_of(other)
{
eq_compare_other_type(op)
} else {
@ -119,7 +119,7 @@ impl PyObjectProtocol for PyNamedNode {
///
/// >>> str(BlankNode('ex'))
/// '_:ex'
#[pyclass(name = BlankNode)]
#[pyclass(name = "BlankNode", module = "oxigraph")]
#[text_signature = "(value)"]
#[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub struct PyBlankNode {
@ -198,9 +198,9 @@ impl PyObjectProtocol for PyBlankNode {
fn __richcmp__(&self, other: &PyAny, op: CompareOp) -> PyResult<bool> {
if let Ok(other) = other.downcast::<PyCell<PyBlankNode>>() {
eq_compare(self, &other.borrow(), op)
} else if PyNamedNode::is_instance(other)
|| PyLiteral::is_instance(other)
|| PyDefaultGraph::is_instance(other)
} else if PyNamedNode::is_type_of(other)
|| PyLiteral::is_type_of(other)
|| PyDefaultGraph::is_type_of(other)
{
eq_compare_other_type(op)
} else {
@ -229,7 +229,7 @@ impl PyObjectProtocol for PyBlankNode {
/// '"example"@en'
/// >>> str(Literal('11', datatype=NamedNode('http://www.w3.org/2001/XMLSchema#integer')))
/// '"11"^^<http://www.w3.org/2001/XMLSchema#integer>'
#[pyclass(name = Literal)]
#[pyclass(name = "Literal", module = "oxigraph")]
#[text_signature = "(value, *, datatype = None, language = None)"]
#[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub struct PyLiteral {
@ -337,9 +337,9 @@ impl PyObjectProtocol for PyLiteral {
fn __richcmp__(&self, other: &PyAny, op: CompareOp) -> PyResult<bool> {
if let Ok(other) = other.downcast::<PyCell<PyLiteral>>() {
eq_compare(self, &other.borrow(), op)
} else if PyNamedNode::is_instance(other)
|| PyBlankNode::is_instance(other)
|| PyDefaultGraph::is_instance(other)
} else if PyNamedNode::is_type_of(other)
|| PyBlankNode::is_type_of(other)
|| PyDefaultGraph::is_type_of(other)
{
eq_compare_other_type(op)
} else {
@ -351,7 +351,7 @@ impl PyObjectProtocol for PyLiteral {
}
/// The RDF `default graph name <https://www.w3.org/TR/rdf11-concepts/#dfn-default-graph>`_
#[pyclass(name = DefaultGraph)]
#[pyclass(name = "DefaultGraph", module = "oxigraph")]
#[derive(Eq, PartialEq, Debug, Clone, Copy, Hash)]
pub struct PyDefaultGraph {}
@ -391,9 +391,9 @@ impl PyObjectProtocol for PyDefaultGraph {
fn __richcmp__(&self, other: &PyAny, op: CompareOp) -> PyResult<bool> {
if let Ok(other) = other.downcast::<PyCell<PyDefaultGraph>>() {
eq_compare(self, &other.borrow(), op)
} else if PyNamedNode::is_instance(other)
|| PyBlankNode::is_instance(other)
|| PyLiteral::is_instance(other)
} else if PyNamedNode::is_type_of(other)
|| PyBlankNode::is_type_of(other)
|| PyLiteral::is_type_of(other)
{
eq_compare_other_type(op)
} else {
@ -453,7 +453,7 @@ impl From<PyTerm> for Term {
/// A triple could also be easily destructed into its components:
///
/// >>> (s, p, o) = Triple(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'))
#[pyclass(name = Triple)]
#[pyclass(name = "Triple", module = "oxigraph")]
#[derive(Eq, PartialEq, Debug, Clone, Hash)]
#[text_signature = "(subject, predicate, object)"]
pub struct PyTriple {
@ -616,7 +616,7 @@ impl From<PyGraphName> for GraphName {
/// A quad could also be easily destructed into its components:
///
/// >>> (s, p, o, g) = Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g'))
#[pyclass(name = Quad)]
#[pyclass(name = "Quad", module = "oxigraph")]
#[text_signature = "(subject, predicate, object, graph_name = None)"]
#[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub struct PyQuad {
@ -792,7 +792,7 @@ impl PyIterProtocol for PyQuad {
///
/// >>> str(Variable('foo'))
/// '?foo'
#[pyclass(name = Variable)]
#[pyclass(name = "Variable", module = "oxigraph")]
#[text_signature = "(value)"]
#[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub struct PyVariable {
@ -873,7 +873,7 @@ impl<'a> TryFrom<&'a PyAny> for PyNamedNodeRef<'a> {
} else {
Err(PyTypeError::new_err(format!(
"{} is not an RDF named node",
value.get_type().name(),
value.get_type().name()?,
)))
}
}
@ -904,7 +904,7 @@ impl<'a> TryFrom<&'a PyAny> for PyNamedOrBlankNodeRef<'a> {
} else {
Err(PyTypeError::new_err(format!(
"{} is not an RDF named or blank node",
value.get_type().name(),
value.get_type().name()?,
)))
}
}
@ -952,7 +952,7 @@ impl<'a> TryFrom<&'a PyAny> for PyTermRef<'a> {
} else {
Err(PyTypeError::new_err(format!(
"{} is not an RDF term",
value.get_type().name(),
value.get_type().name()?,
)))
}
}
@ -1001,7 +1001,7 @@ impl<'a> TryFrom<&'a PyAny> for PyGraphNameRef<'a> {
} else {
Err(PyTypeError::new_err(format!(
"{} is not an RDF graph name",
value.get_type().name(),
value.get_type().name()?,
)))
}
}
@ -1093,7 +1093,7 @@ fn graph_name_repr(term: GraphNameRef<'_>, buffer: &mut String) {
}
}
#[pyclass]
#[pyclass(module = "oxigraph")]
pub struct TripleComponentsIter {
inner: IntoIter<Term>,
}
@ -1109,7 +1109,7 @@ impl PyIterProtocol for TripleComponentsIter {
}
}
#[pyclass]
#[pyclass(module = "oxigraph")]
pub struct QuadComponentsIter {
inner: IntoIter<Option<Term>>,
}

@ -29,7 +29,7 @@ use std::io::BufReader;
/// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g')))
/// >>> str(store)
/// '<http://example.com> <http://example.com/p> "1" <http://example.com/g> .\n'
#[pyclass(name = SledStore)]
#[pyclass(name = "SledStore", module = "oxigraph")]
#[text_signature = "(path = None)"]
#[derive(Clone)]
pub struct PySledStore {
@ -391,7 +391,7 @@ impl PyIterProtocol for PySledStore {
}
}
#[pyclass]
#[pyclass(module = "oxigraph")]
pub struct QuadIter {
inner: SledQuadIter,
}

@ -85,7 +85,7 @@ pub fn query_results_to_python(py: Python<'_>, results: QueryResults) -> PyResul
/// >>> s, p, o = solution
/// >>> s
/// <NamedNode value=http://example.com>
#[pyclass(unsendable, name = QuerySolution)]
#[pyclass(unsendable, name = "QuerySolution", module = "oxigraph")]
pub struct PyQuerySolution {
inner: QuerySolution,
}
@ -132,7 +132,7 @@ impl PyMappingProtocol for PyQuerySolution {
} else {
Err(PyTypeError::new_err(format!(
"{} is not an integer of a string",
input.get_type().name(),
input.get_type().name()?,
)))
}
}
@ -152,7 +152,7 @@ impl PyIterProtocol for PyQuerySolution {
}
}
#[pyclass]
#[pyclass(module = "oxigraph")]
pub struct SolutionValueIter {
inner: IntoIter<Option<Term>>,
}
@ -176,7 +176,7 @@ impl PyIterProtocol for SolutionValueIter {
/// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1')))
/// >>> list(store.query('SELECT ?s WHERE { ?s ?p ?o }'))
/// [<QuerySolution s=<NamedNode value=http://example.com>>]
#[pyclass(unsendable, name = QuerySolutions)]
#[pyclass(unsendable, name = "QuerySolutions", module = "oxigraph")]
pub struct PyQuerySolutions {
inner: QuerySolutionIter,
}
@ -221,7 +221,7 @@ impl PyIterProtocol for PyQuerySolutions {
/// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1')))
/// >>> list(store.query('CONSTRUCT WHERE { ?s ?p ?o }'))
/// [<Triple 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>>>]
#[pyclass(unsendable, name = QueryTriples)]
#[pyclass(unsendable, name = "QueryTriples", module = "oxigraph")]
pub struct PyQueryTriples {
inner: QueryTripleIter,
}

Loading…
Cancel
Save