feat(python): add interface file and other small changes
This commit is contained in:
parent
168e881884
commit
c42f892099
8 changed files with 373 additions and 31 deletions
|
|
@ -2,8 +2,31 @@ mod expr;
|
|||
mod semantics;
|
||||
mod signals;
|
||||
|
||||
use argus_core::ArgusError;
|
||||
use pyo3::exceptions::{PyKeyError, PyRuntimeError, PyTypeError, PyValueError};
|
||||
use pyo3::prelude::*;
|
||||
|
||||
#[derive(derive_more::From)]
|
||||
struct PyArgusError(ArgusError);
|
||||
|
||||
impl From<PyArgusError> for PyErr {
|
||||
fn from(value: PyArgusError) -> Self {
|
||||
use argus_core::Error::*;
|
||||
match value.0 {
|
||||
err @ (IncompleteArgs | InvalidOperation | IdentifierRedeclaration) => {
|
||||
PyValueError::new_err(err.to_string())
|
||||
}
|
||||
err @ (InvalidPushToSignal
|
||||
| NonMonotonicSignal {
|
||||
end_time: _,
|
||||
current_sample: _,
|
||||
}) => PyRuntimeError::new_err(err.to_string()),
|
||||
err @ SignalNotPresent => PyKeyError::new_err(err.to_string()),
|
||||
err @ (InvalidSignalType | InvalidCast { from: _, to: _ }) => PyTypeError::new_err(err.to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[pymodule]
|
||||
#[pyo3(name = "_argus")]
|
||||
fn pyargus(py: Python, m: &PyModule) -> PyResult<()> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue