-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.rs
More file actions
36 lines (31 loc) · 1.1 KB
/
lib.rs
File metadata and controls
36 lines (31 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
mod constants;
mod converter;
mod errors;
mod match_parsers;
mod parsers;
use pyo3::prelude::*;
use pyo3::{PyResult, types::PyModule};
/// Модуль для реализации функций модуля `docs_parser`
mod parser {
use pyo3::prelude::*;
/// Парсинг текста `from` файла по `path`
#[pyo3::pyfunction]
pub fn get_text(from_path: &str) -> PyResult<String> {
Ok(crate::match_parsers::get_text(from_path)?)
}
/// Конвертер старых Microsoft office форматов в новые
#[pyo3::pyfunction]
pub fn convert_to_new_format(old_file_path: &str, new_path: &str) -> PyResult<()> {
Ok(crate::converter::convert_to_new_format(
old_file_path,
new_path,
)?)
}
}
/// Функция реализации python модуля, добавляющая в него функции
#[pymodule]
fn docs_parser(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_function(wrap_pyfunction!(parser::get_text, m)?)?;
m.add_function(wrap_pyfunction!(parser::convert_to_new_format, m)?)?;
Ok(())
}