Skip to content

Commit

Permalink
Release 0.1.40
Browse files Browse the repository at this point in the history
[email protected]
[email protected]

Generated by cargo-workspaces
  • Loading branch information
labra committed Oct 28, 2024
1 parent 3647295 commit 2726377
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 78 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

## Current changes without release yet

## [0.1.37] - 2024-10-28

- Added more features to the rudof_lib like the serialization of ShEx, SHACL and Shapemaps which is also mirrored in the Python bindings

## [0.1.36] - 2024-10-27

- Python bindings based on rudof_lib
- Python bindings based on rudof_lib to validate ShEx and SHACL

## [0.1.35] - 2024-10-25

Expand Down
2 changes: 1 addition & 1 deletion python/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pyrudof"
version = "0.1.39"
version = "0.1.40"
documentation = "https://rudof-project.github.io/rudof/"
readme = "README.md"
license.workspace = true
Expand Down
156 changes: 83 additions & 73 deletions python/src/pyrudof_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,178 +220,192 @@ impl PyRudof {
}
}

#[pyclass(name = "ShapeMapFormat")]
#[pyclass(frozen, name = "ShapeMapFormat")]
pub struct PyShapeMapFormat {
inner: ShapeMapFormat,
}

#[pymethods]
impl PyShapeMapFormat {
#[new]
fn __init__(py: Python<'_>) -> PyResult<Self> {
py.allow_threads(|| {
Ok(Self {
inner: ShapeMapFormat::default(),
})
fn __init__(py: Python<'_>) -> Self {
py.allow_threads(|| Self {
inner: ShapeMapFormat::default(),
})
}

/// Returns `Turtle` format
/// Returns `Compact` format
#[staticmethod]
fn compact() -> PyResult<Self> {
Ok(Self {
fn compact() -> Self {
Self {
inner: ShapeMapFormat::Compact,
})
}
}

/// Returns `ShExC` format
/// Returns `JSON` format
#[staticmethod]
fn json() -> PyResult<Self> {
Ok(Self {
fn json() -> Self {
Self {
inner: ShapeMapFormat::JSON,
})
}
}
}

#[pyclass(name = "ShExFormat")]
#[pyclass(frozen, name = "ShExFormat")]
pub struct PyShExFormat {
inner: ShExFormat,
}

#[pymethods]
impl PyShExFormat {
#[new]
fn __init__(py: Python<'_>) -> PyResult<Self> {
py.allow_threads(|| {
Ok(Self {
inner: ShExFormat::default(),
})
fn __init__(py: Python<'_>) -> Self {
py.allow_threads(|| Self {
inner: ShExFormat::default(),
})
}

/// Returns `Turtle` format
#[staticmethod]
fn turtle() -> PyResult<Self> {
Ok(Self {
fn turtle() -> Self {
Self {
inner: ShExFormat::Turtle,
})
}
}

/// Returns `ShExC` format
#[staticmethod]
fn shexc() -> PyResult<Self> {
Ok(Self {
fn shexc() -> Self {
Self {
inner: ShExFormat::ShExC,
})
}
}

/// Returns `ShExJ` format
#[staticmethod]
fn shexj() -> PyResult<Self> {
Ok(Self {
fn shexj() -> Self {
Self {
inner: ShExFormat::ShExJ,
})
}
}
}

#[pyclass(name = "ShaclFormat")]
#[pyclass(frozen, name = "ShaclFormat")]
pub struct PyShaclFormat {
inner: ShaclFormat,
}

#[pymethods]
impl PyShaclFormat {
#[new]
fn __init__(py: Python<'_>) -> PyResult<Self> {
py.allow_threads(|| {
Ok(Self {
inner: ShaclFormat::default(),
})
fn __init__(py: Python<'_>) -> Self {
py.allow_threads(|| Self {
inner: ShaclFormat::default(),
})
}

/// Returns `Turtle` format
#[staticmethod]
fn turtle() -> PyResult<Self> {
Ok(Self {
fn turtle() -> Self {
Self {
inner: ShaclFormat::Turtle,
})
}
}

/// Returns `N-Triples` format
#[staticmethod]
fn ntriples() -> PyResult<Self> {
Ok(Self {
fn ntriples() -> Self {
Self {
inner: ShaclFormat::NTriples,
})
}
}

/// Returns `RDFXML` format
#[staticmethod]
fn rdfxml() -> PyResult<Self> {
Ok(Self {
fn rdfxml() -> Self {
Self {
inner: ShaclFormat::RDFXML,
})
}
}

// TODO...add more constructors...
}

#[pyclass(name = "ShExFormatter")]
#[pyclass(frozen, name = "ShExFormatter")]
pub struct PyShExFormatter {
inner: ShExFormatter,
}

#[pymethods]
impl PyShExFormatter {
#[new]
fn __init__(py: Python<'_>) -> PyResult<Self> {
py.allow_threads(|| {
Ok(Self {
inner: ShExFormatter::default(),
})
fn __init__(py: Python<'_>) -> Self {
py.allow_threads(|| Self {
inner: ShExFormatter::default(),
})
}

/// Returns a ShExFormatter that doesn't print terminal colors
#[staticmethod]
fn without_colors() -> PyResult<Self> {
Ok(Self {
fn without_colors() -> Self {
Self {
inner: ShExFormatter::default().without_colors(),
})
}
}
}

#[pyclass(name = "ShapeMapFormatter")]
#[pyclass(frozen, name = "ShapeMapFormatter")]
pub struct PyShapeMapFormatter {
inner: ShapeMapFormatter,
}

#[pymethods]
impl PyShapeMapFormatter {
#[new]
fn __init__(py: Python<'_>) -> PyResult<Self> {
py.allow_threads(|| {
Ok(Self {
inner: ShapeMapFormatter::default(),
})
fn __init__(py: Python<'_>) -> Self {
py.allow_threads(|| Self {
inner: ShapeMapFormatter::default(),
})
}

/// Returns a Shapemap formatter that doesn't print terminal colors
#[staticmethod]
fn without_colors() -> PyResult<Self> {
Ok(Self {
fn without_colors() -> Self {
Self {
inner: ShapeMapFormatter::default().without_colors(),
})
}
}
}

#[pyclass(name = "PyUmlGenerationMode")]
#[pyclass(frozen, name = "PyUmlGenerationMode")]
pub struct PyUmlGenerationMode {
inner: UmlGenerationMode,
}

#[pymethods]
impl PyUmlGenerationMode {
#[new]
fn __init__(py: Python<'_>) -> Self {
py.allow_threads(|| Self {
inner: UmlGenerationMode::default(),
})
}

#[staticmethod]
fn all() -> Self {
Self {
inner: UmlGenerationMode::all(),
}
}

#[staticmethod]
fn neighs(node: &str) -> Self {
Self {
inner: UmlGenerationMode::neighs(node),
}
}
}

#[pyclass(name = "ShExSchema")]
pub struct PyShExSchema {
_inner: ShExSchema,
Expand Down Expand Up @@ -431,11 +445,9 @@ pub struct PyShaclValidationMode {
#[pymethods]
impl PyShaclValidationMode {
#[new]
fn __init__(py: Python<'_>) -> PyResult<Self> {
py.allow_threads(|| {
Ok(Self {
inner: ShaclValidationMode::default(),
})
fn __init__(py: Python<'_>) -> Self {
py.allow_threads(|| Self {
inner: ShaclValidationMode::default(),
})
}
}
Expand All @@ -448,11 +460,9 @@ pub struct PyShapesGraphSource {
#[pymethods]
impl PyShapesGraphSource {
#[new]
fn __init__(py: Python<'_>) -> PyResult<Self> {
py.allow_threads(|| {
Ok(Self {
inner: ShapesGraphSource::default(),
})
fn __init__(py: Python<'_>) -> Self {
py.allow_threads(|| Self {
inner: ShapesGraphSource::default(),
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion shapes_converter/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "shapes_converter"
version = "0.1.33"
version = "0.1.40"
authors.workspace = true
description.workspace = true
documentation = "https://docs.rs/shapes_converter"
Expand Down
6 changes: 4 additions & 2 deletions shapes_converter/src/shex_to_uml/shex2uml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,10 @@ pub enum ImageFormat {
PNG,
}

#[derive(Debug, Clone, Default)]
pub enum UmlGenerationMode {
/// Show all nodes
#[default]
AllNodes,

/// Show only the neighbours of a node
Expand All @@ -440,8 +442,8 @@ impl UmlGenerationMode {
UmlGenerationMode::AllNodes
}

pub fn neighs(str: &str) -> UmlGenerationMode {
UmlGenerationMode::Neighs(str.to_string())
pub fn neighs(node: &str) -> UmlGenerationMode {
UmlGenerationMode::Neighs(node.to_string())
}
}

Expand Down

0 comments on commit 2726377

Please sign in to comment.