Show More
@@ -0,0 +1,4 | |||||
|
1 | use pyo3::create_exception; | |||
|
2 | use pyo3::exceptions::PyValueError; | |||
|
3 | ||||
|
4 | create_exception!(pyo3_rustext, GraphError, PyValueError); |
@@ -1,19 +1,21 | |||||
1 | use pyo3::prelude::*; |
|
1 | use pyo3::prelude::*; | |
2 |
|
2 | |||
3 | mod dagops; |
|
3 | mod dagops; | |
|
4 | mod exceptions; | |||
4 | mod util; |
|
5 | mod util; | |
5 |
|
6 | |||
6 | #[pymodule] |
|
7 | #[pymodule] | |
7 | fn pyo3_rustext(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> { |
|
8 | fn pyo3_rustext(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> { | |
8 | m.add( |
|
9 | m.add( | |
9 | "__doc__", |
|
10 | "__doc__", | |
10 | "Mercurial core concepts - Rust implementation exposed via PyO3", |
|
11 | "Mercurial core concepts - Rust implementation exposed via PyO3", | |
11 | )?; |
|
12 | )?; | |
12 | // the module's __name__ is pyo3_rustext, not mercurial.pyo3_rustext |
|
13 | // the module's __name__ is pyo3_rustext, not mercurial.pyo3_rustext | |
13 | // (at least at this point). |
|
14 | // (at least at this point). | |
14 | let name: String = m.getattr("__name__")?.extract()?; |
|
15 | let name: String = m.getattr("__name__")?.extract()?; | |
15 | let dotted_name = format!("mercurial.{}", name); |
|
16 | let dotted_name = format!("mercurial.{}", name); | |
16 |
|
17 | |||
17 | m.add_submodule(&dagops::init_module(py, &dotted_name)?)?; |
|
18 | m.add_submodule(&dagops::init_module(py, &dotted_name)?)?; | |
|
19 | m.add("GraphError", py.get_type::<exceptions::GraphError>())?; | |||
18 | Ok(()) |
|
20 | Ok(()) | |
19 | } |
|
21 | } |
General Comments 0
You need to be logged in to leave comments.
Login now