Python: adds proper module medata to classes

pull/430/head
Tpt 2 years ago committed by Thomas Tanon
parent 7b74fa9b0a
commit 935e778db1
  1. 4
      python/src/io.rs
  2. 18
      python/src/model.rs
  3. 8
      python/src/sparql.rs
  4. 6
      python/src/store.rs

@ -153,7 +153,7 @@ pub fn serialize(input: &PyAny, output: PyObject, mime_type: &str, py: Python<'_
} }
} }
#[pyclass(name = "TripleReader")] #[pyclass(name = "TripleReader", module = "pyoxigraph")]
pub struct PyTripleReader { pub struct PyTripleReader {
inner: TripleReader<PyReadable>, inner: TripleReader<PyReadable>,
} }
@ -174,7 +174,7 @@ impl PyTripleReader {
} }
} }
#[pyclass(name = "QuadReader")] #[pyclass(name = "QuadReader", module = "pyoxigraph")]
pub struct PyQuadReader { pub struct PyQuadReader {
inner: QuadReader<PyReadable>, inner: QuadReader<PyReadable>,
} }

@ -19,7 +19,7 @@ use std::vec::IntoIter;
/// ///
/// >>> str(NamedNode('http://example.com')) /// >>> str(NamedNode('http://example.com'))
/// '<http://example.com>' /// '<http://example.com>'
#[pyclass(name = "NamedNode")] #[pyclass(name = "NamedNode", module = "pyoxigraph")]
#[pyo3(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 {
@ -121,7 +121,7 @@ impl PyNamedNode {
/// ///
/// >>> str(BlankNode('ex')) /// >>> str(BlankNode('ex'))
/// '_:ex' /// '_:ex'
#[pyclass(name = "BlankNode")] #[pyclass(name = "BlankNode", module = "pyoxigraph")]
#[pyo3(text_signature = "(value = None)")] #[pyo3(text_signature = "(value = None)")]
#[derive(Eq, PartialEq, Debug, Clone, Hash)] #[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub struct PyBlankNode { pub struct PyBlankNode {
@ -235,7 +235,7 @@ impl PyBlankNode {
/// '"example"@en' /// '"example"@en'
/// >>> 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")] #[pyclass(name = "Literal", module = "pyoxigraph")]
#[pyo3(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 {
@ -354,7 +354,7 @@ impl PyLiteral {
} }
/// The RDF `default graph name <https://www.w3.org/TR/rdf11-concepts/#dfn-default-graph>`_. /// The RDF `default graph name <https://www.w3.org/TR/rdf11-concepts/#dfn-default-graph>`_.
#[pyclass(name = "DefaultGraph")] #[pyclass(name = "DefaultGraph", module = "pyoxigraph")]
#[pyo3(text_signature = "()")] #[pyo3(text_signature = "()")]
#[derive(Eq, PartialEq, Debug, Clone, Copy, Hash)] #[derive(Eq, PartialEq, Debug, Clone, Copy, Hash)]
pub struct PyDefaultGraph {} pub struct PyDefaultGraph {}
@ -535,7 +535,7 @@ impl IntoPy<PyObject> for PyTerm {
/// A triple could also be easily destructed into its components: /// 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')) /// >>> (s, p, o) = Triple(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'))
#[pyclass(name = "Triple")] #[pyclass(name = "Triple", module = "pyoxigraph")]
#[derive(Eq, PartialEq, Debug, Clone, Hash)] #[derive(Eq, PartialEq, Debug, Clone, Hash)]
#[pyo3(text_signature = "(subject, predicate, object)")] #[pyo3(text_signature = "(subject, predicate, object)")]
pub struct PyTriple { pub struct PyTriple {
@ -712,7 +712,7 @@ impl IntoPy<PyObject> for PyGraphName {
/// A quad could also be easily destructed into its components: /// 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')) /// >>> (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 = "pyoxigraph")]
#[pyo3(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 {
@ -873,7 +873,7 @@ impl PyQuad {
/// ///
/// >>> str(Variable('foo')) /// >>> str(Variable('foo'))
/// '?foo' /// '?foo'
#[pyclass(name = "Variable")] #[pyclass(name = "Variable", module = "pyoxigraph")]
#[pyo3(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 {
@ -1187,7 +1187,7 @@ fn triple_repr(triple: TripleRef<'_>, buffer: &mut String) {
buffer.push('>'); buffer.push('>');
} }
#[pyclass] #[pyclass(module = "pyoxigraph")]
pub struct TripleComponentsIter { pub struct TripleComponentsIter {
inner: IntoIter<Term>, inner: IntoIter<Term>,
} }
@ -1203,7 +1203,7 @@ impl TripleComponentsIter {
} }
} }
#[pyclass] #[pyclass(module = "pyoxigraph")]
pub struct QuadComponentsIter { pub struct QuadComponentsIter {
inner: IntoIter<Option<Term>>, inner: IntoIter<Option<Term>>,
} }

@ -84,7 +84,7 @@ pub fn query_results_to_python(py: Python<'_>, results: QueryResults) -> PyResul
/// >>> s, p, o = solution /// >>> s, p, o = solution
/// >>> s /// >>> s
/// <NamedNode value=http://example.com> /// <NamedNode value=http://example.com>
#[pyclass(unsendable, name = "QuerySolution")] #[pyclass(unsendable, name = "QuerySolution", module = "pyoxigraph")]
pub struct PyQuerySolution { pub struct PyQuerySolution {
inner: QuerySolution, inner: QuerySolution,
} }
@ -134,7 +134,7 @@ impl PyQuerySolution {
} }
} }
#[pyclass] #[pyclass(module = "pyoxigraph")]
pub struct SolutionValueIter { pub struct SolutionValueIter {
inner: IntoIter<Option<Term>>, inner: IntoIter<Option<Term>>,
} }
@ -156,7 +156,7 @@ impl SolutionValueIter {
/// >>> 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')))
/// >>> list(store.query('SELECT ?s WHERE { ?s ?p ?o }')) /// >>> list(store.query('SELECT ?s WHERE { ?s ?p ?o }'))
/// [<QuerySolution s=<NamedNode value=http://example.com>>] /// [<QuerySolution s=<NamedNode value=http://example.com>>]
#[pyclass(unsendable, name = "QuerySolutions")] #[pyclass(unsendable, name = "QuerySolutions", module = "pyoxigraph")]
pub struct PyQuerySolutions { pub struct PyQuerySolutions {
inner: QuerySolutionIter, inner: QuerySolutionIter,
} }
@ -196,7 +196,7 @@ impl PyQuerySolutions {
/// >>> 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')))
/// >>> list(store.query('CONSTRUCT WHERE { ?s ?p ?o }')) /// >>> 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>>>] /// [<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 = "pyoxigraph")]
pub struct PyQueryTriples { pub struct PyQueryTriples {
inner: QueryTripleIter, inner: QueryTripleIter,
} }

@ -35,7 +35,7 @@ use pyo3::prelude::*;
/// >>> 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')))
/// >>> 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 = "Store")] #[pyclass(name = "Store", module = "pyoxigraph")]
#[pyo3(text_signature = "(path = None)")] #[pyo3(text_signature = "(path = None)")]
#[derive(Clone)] #[derive(Clone)]
pub struct PyStore { pub struct PyStore {
@ -768,7 +768,7 @@ impl PyStore {
} }
} }
#[pyclass(unsendable)] #[pyclass(unsendable, module = "pyoxigraph")]
pub struct QuadIter { pub struct QuadIter {
inner: store::QuadIter, inner: store::QuadIter,
} }
@ -787,7 +787,7 @@ impl QuadIter {
} }
} }
#[pyclass(unsendable)] #[pyclass(unsendable, module = "pyoxigraph")]
pub struct GraphNameIter { pub struct GraphNameIter {
inner: store::GraphNameIter, inner: store::GraphNameIter,
} }

Loading…
Cancel
Save