mirror of
https://github.com/dathere/ckan_geoconnex_bulk_runner.git
synced 2026-07-05 15:12:20 +00:00
feat: multi-CKAN-instance compatibility
This commit is contained in:
parent
59564c9de3
commit
7c8fac233e
6 changed files with 55 additions and 33 deletions
|
|
@ -6,25 +6,25 @@ use pyo3::prelude::*;
|
|||
mod ckan_geoconnex_bulk_runner_py {
|
||||
use pyo3::{exceptions::PyException, prelude::*};
|
||||
|
||||
#[pyfunction]
|
||||
/// Construct Geoconnex-compatible JSON-LD as a string from dataset metadata.
|
||||
///
|
||||
/// Input: Dataset metadata (output of /package_show for a CKAN dataset) as a string.
|
||||
/// Output: Constructed Geoconnex-compatible JSON-LD as a string.
|
||||
fn construct_dataset_jsonld_from_metadata(dataset_metadata: String) -> PyResult<String> {
|
||||
match serde_json::to_value(dataset_metadata) {
|
||||
Ok(dataset_json) => {
|
||||
match geoconnex_utils::jsonld::construct_dataset_jsonld_from_metadata(dataset_json)
|
||||
{
|
||||
Ok(jsonld) => serde_json::to_string(&jsonld).map_err(|e| {
|
||||
PyException::new_err(format!(
|
||||
"Error when converting JSON-LD to string: {e}"
|
||||
))
|
||||
}),
|
||||
Err(e) => Err(PyException::new_err(e.to_string())),
|
||||
}
|
||||
}
|
||||
Err(e) => Err(PyException::new_err(e.to_string())),
|
||||
}
|
||||
}
|
||||
// #[pyfunction]
|
||||
// Construct Geoconnex-compatible JSON-LD as a string from dataset metadata.
|
||||
//
|
||||
// Input: Dataset metadata (output of /package_show for a CKAN dataset) as a string.
|
||||
// Output: Constructed Geoconnex-compatible JSON-LD as a string.
|
||||
// fn construct_dataset_jsonld_from_metadata(dataset_metadata: String) -> PyResult<String> {
|
||||
// match serde_json::to_value(dataset_metadata) {
|
||||
// Ok(dataset_json) => {
|
||||
// match geoconnex_utils::jsonld::construct_dataset_jsonld_from_metadata(dataset_json)
|
||||
// {
|
||||
// Ok(jsonld) => serde_json::to_string(&jsonld).map_err(|e| {
|
||||
// PyException::new_err(format!(
|
||||
// "Error when converting JSON-LD to string: {e}"
|
||||
// ))
|
||||
// }),
|
||||
// Err(e) => Err(PyException::new_err(e.to_string())),
|
||||
// }
|
||||
// }
|
||||
// Err(e) => Err(PyException::new_err(e.to_string())),
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue