@@ -10,8 +10,11 @@ pub use prelude_xml_parser::native::{
1010 site_native:: SiteNative , subject_native:: SubjectNative , user_native:: UserNative ,
1111} ;
1212use prelude_xml_parser:: parse_site_native_file as parse_site_native_file_rs;
13+ use prelude_xml_parser:: parse_site_native_string as parse_site_native_string_rs;
1314use prelude_xml_parser:: parse_subject_native_file as parse_subject_native_file_rs;
15+ use prelude_xml_parser:: parse_subject_native_string as parse_subject_native_string_rs;
1416use prelude_xml_parser:: parse_user_native_file as parse_user_native_file_rs;
17+ use prelude_xml_parser:: parse_user_native_string as parse_user_native_string_rs;
1518use pyo3:: prelude:: * ;
1619use pyo3:: types:: { IntoPyDict , PyDict , PyList } ;
1720use roxmltree:: Document ;
@@ -244,6 +247,14 @@ fn parse_site_native_file(_py: Python, xml_file: PathBuf) -> PyResult<SiteNative
244247 }
245248}
246249
250+ #[ pyfunction]
251+ fn parse_site_native_string ( _py : Python , xml_str : & str ) -> PyResult < SiteNative > {
252+ match parse_site_native_string_rs ( xml_str) {
253+ Ok ( native) => Ok ( native) ,
254+ Err ( e) => Err ( ParsingError :: new_err ( format ! ( "Error parsing xml: {:?}" , e) ) ) ,
255+ }
256+ }
257+
247258#[ pyfunction]
248259fn parse_subject_native_file ( _py : Python , xml_file : PathBuf ) -> PyResult < SubjectNative > {
249260 match parse_subject_native_file_rs ( & xml_file) {
@@ -255,6 +266,14 @@ fn parse_subject_native_file(_py: Python, xml_file: PathBuf) -> PyResult<Subject
255266 }
256267}
257268
269+ #[ pyfunction]
270+ fn parse_subject_native_string ( _py : Python , xml_str : & str ) -> PyResult < SubjectNative > {
271+ match parse_subject_native_string_rs ( xml_str) {
272+ Ok ( native) => Ok ( native) ,
273+ Err ( e) => Err ( ParsingError :: new_err ( format ! ( "Error parsing xml: {:?}" , e) ) ) ,
274+ }
275+ }
276+
258277#[ pyfunction]
259278fn parse_user_native_file ( _py : Python , xml_file : PathBuf ) -> PyResult < UserNative > {
260279 match parse_user_native_file_rs ( & xml_file) {
@@ -266,6 +285,14 @@ fn parse_user_native_file(_py: Python, xml_file: PathBuf) -> PyResult<UserNative
266285 }
267286}
268287
288+ #[ pyfunction]
289+ fn parse_user_native_string ( _py : Python , xml_str : & str ) -> PyResult < UserNative > {
290+ match parse_user_native_string_rs ( xml_str) {
291+ Ok ( native) => Ok ( native) ,
292+ Err ( e) => Err ( ParsingError :: new_err ( format ! ( "Error parsing xml: {:?}" , e) ) ) ,
293+ }
294+ }
295+
269296#[ pymodule]
270297fn _prelude_parser ( py : Python , m : & Bound < ' _ , PyModule > ) -> PyResult < ( ) > {
271298 m. add_class :: < SiteNative > ( ) ?;
@@ -274,8 +301,11 @@ fn _prelude_parser(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
274301 m. add_function ( wrap_pyfunction ! ( _parse_flat_file_to_dict, m) ?) ?;
275302 m. add_function ( wrap_pyfunction ! ( _parse_flat_file_to_pandas_dict, m) ?) ?;
276303 m. add_function ( wrap_pyfunction ! ( parse_site_native_file, m) ?) ?;
304+ m. add_function ( wrap_pyfunction ! ( parse_site_native_string, m) ?) ?;
277305 m. add_function ( wrap_pyfunction ! ( parse_subject_native_file, m) ?) ?;
306+ m. add_function ( wrap_pyfunction ! ( parse_subject_native_string, m) ?) ?;
278307 m. add_function ( wrap_pyfunction ! ( parse_user_native_file, m) ?) ?;
308+ m. add_function ( wrap_pyfunction ! ( parse_user_native_string, m) ?) ?;
279309 m. add (
280310 "FileNotFoundError" ,
281311 py. get_type_bound :: < FileNotFoundError > ( ) ,
0 commit comments