Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
helgee committed Nov 12, 2024
1 parent c039ea4 commit cee25d4
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions crates/lox-ephem/src/python.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use pyo3::{exceptions::PyValueError, pyclass, pymethods, PyErr, PyResult};

use crate::spk::parser::{parse_daf_spk, DafSpkError, Spk};

impl From<DafSpkError> for PyErr {
fn from(err: DafSpkError) -> Self {
PyValueError::new_err(err.to_string())
}

Check warning on line 8 in crates/lox-ephem/src/python.rs

View check run for this annotation

Codecov / codecov/patch

crates/lox-ephem/src/python.rs#L6-L8

Added lines #L6 - L8 were not covered by tests
}

#[pyclass(name = "SPK", module = "lox_space", frozen)]

Check warning on line 11 in crates/lox-ephem/src/python.rs

View check run for this annotation

Codecov / codecov/patch

crates/lox-ephem/src/python.rs#L11

Added line #L11 was not covered by tests
pub struct PySpk(pub Spk);

#[pymethods]

Check warning on line 14 in crates/lox-ephem/src/python.rs

View check run for this annotation

Codecov / codecov/patch

crates/lox-ephem/src/python.rs#L14

Added line #L14 was not covered by tests
impl PySpk {
#[new]
fn new(path: &str) -> PyResult<Self> {
let data = std::fs::read(path)?;
let spk = parse_daf_spk(&data)?;
Ok(PySpk(spk))
}

Check warning on line 21 in crates/lox-ephem/src/python.rs

View check run for this annotation

Codecov / codecov/patch

crates/lox-ephem/src/python.rs#L17-L21

Added lines #L17 - L21 were not covered by tests
}

0 comments on commit cee25d4

Please sign in to comment.