2525#![ allow( non_snake_case) ]
2626#![ allow( clippy:: needless_return) ]
2727
28- use libmathcat:: interface :: StringOrFloat ;
28+ use libmathcat:: * ;
2929use pyo3:: prelude:: * ;
3030use pyo3:: wrap_pyfunction;
3131use pyo3:: exceptions:: PyOSError ;
@@ -36,7 +36,7 @@ fn convert_error<T>(result: Result<T, libmathcat::errors::Error>) -> PyResult<T>
3636 return match result {
3737 Ok ( answer) => Ok ( answer) ,
3838 Err ( e) => {
39- Err ( PyOSError :: new_err ( libmathcat :: interface :: errors_to_string ( & e) ) )
39+ Err ( PyOSError :: new_err ( errors_to_string ( & e) ) )
4040 } ,
4141 } ;
4242}
@@ -45,7 +45,7 @@ fn convert_error<T>(result: Result<T, libmathcat::errors::Error>) -> PyResult<T>
4545/// The absolute path location of the MathCAT Rules dir.
4646/// IMPORTANT: This should be the first call to MathCAT
4747pub fn SetRulesDir ( _py : Python , rules_dir_location : String ) -> PyResult < ( ) > {
48- return convert_error ( libmathcat :: interface :: SetRulesDir ( rules_dir_location) ) ;
48+ return convert_error ( set_rules_dir ( rules_dir_location) ) ;
4949}
5050
5151#[ pyfunction]
@@ -55,13 +55,13 @@ pub fn SetRulesDir(_py: Python, rules_dir_location: String) -> PyResult<()> {
5555/// Returns: the MathML that was set, annotated with 'id' values on each node (if none were present)
5656/// The 'id' values can be used during navigation for highlighting the current node
5757pub fn SetMathML ( _py : Python , mathml_str : String ) -> PyResult < String > {
58- return convert_error ( libmathcat :: interface :: SetMathML ( mathml_str) ) ;
58+ return convert_error ( set_mathml ( mathml_str) ) ;
5959}
6060#[ pyfunction]
6161/// Get the spoken text of the MathML that was set.
6262/// The speech takes into account any AT or user preferences.
6363pub fn GetSpokenText ( _py : Python ) -> PyResult < String > {
64- return convert_error ( libmathcat :: interface :: GetSpokenText ( ) ) ;
64+ return convert_error ( get_spoken_text ( ) ) ;
6565}
6666
6767#[ pyfunction]
@@ -71,12 +71,7 @@ pub fn GetSpokenText(_py: Python) -> PyResult<String> {
7171/// This function can be called multiple times to set different values.
7272/// The values are persistent but can be overwritten by setting a preference with the same name and a different value.
7373pub fn SetPreference ( _py : Python , name : String , value : String ) -> PyResult < ( ) > {
74- let as_float = value. parse :: < f64 > ( ) ;
75- let str_or_float = match as_float {
76- Ok ( f) => StringOrFloat :: AsFloat ( f) ,
77- Err ( _) => StringOrFloat :: AsString ( value) ,
78- } ;
79- return convert_error ( libmathcat:: interface:: SetPreference ( name, str_or_float) ) ;
74+ return convert_error ( set_preference ( name, value) ) ;
8075}
8176
8277#[ pyfunction]
@@ -86,7 +81,7 @@ pub fn SetPreference(_py: Python, name: String, value: String) -> PyResult<()> {
8681/// This function can be called multiple times to set different values.
8782/// The values are persistent but can be overwritten by setting a preference with the same name and a different value.
8883pub fn GetPreference ( _py : Python , name : String ) -> PyResult < String > {
89- return match libmathcat :: interface :: GetPreference ( name) {
84+ return match get_preference ( name) {
9085 Some ( value) => Ok ( value) ,
9186 None => Err ( PyOSError :: new_err ( "Unknown preference name" ) ) ,
9287 }
@@ -99,15 +94,15 @@ pub fn GetPreference(_py: Python, name: String) -> PyResult<String> {
9994///
10095/// The braille returned depends upon the preference for braille output.
10196pub fn GetBraille ( _py : Python , nav_node_id : String ) -> PyResult < String > {
102- return convert_error ( libmathcat :: interface :: GetBraille ( nav_node_id) ) ;
97+ return convert_error ( get_braille ( nav_node_id) ) ;
10398}
10499
105100#[ pyfunction]
106101/// Given a key code along with the modifier keys, the current node is moved accordingly (or value reported in some cases).
107102///
108103/// The spoken text for the new current node is returned.
109104pub fn DoNavigateKeyPress ( _py : Python , key : usize , shift_key : bool , control_key : bool , alt_key : bool , meta_key : bool ) -> PyResult < String > {
110- return convert_error ( libmathcat :: interface :: DoNavigateKeyPress ( key, shift_key, control_key, alt_key, meta_key) ) ;
105+ return convert_error ( do_navigate_keypress ( key, shift_key, control_key, alt_key, meta_key) ) ;
111106}
112107
113108#[ pyfunction]
@@ -130,19 +125,19 @@ pub fn DoNavigateKeyPress(_py: Python, key: usize, shift_key: bool, control_key:
130125/// "Describe0","Describe1","Describe2","Describe3","Describe4","Describe5","Describe6","Describe7","Describe8","Describe9",
131126/// "SetPlacemarker0","SetPlacemarker1","SetPlacemarker2","SetPlacemarker3","SetPlacemarker4","SetPlacemarker5","SetPlacemarker6","SetPlacemarker7","SetPlacemarker8","SetPlacemarker9",
132127pub fn DoNavigateCommand ( _py : Python , command : String ) -> PyResult < String > {
133- return convert_error ( libmathcat :: interface :: DoNavigateCommand ( command) ) ;
128+ return convert_error ( do_navigate_command ( command) ) ;
134129}
135130
136131#[ pyfunction]
137132/// Return the MathML associated with the current (navigation) node.
138133pub fn GetNavigationMathMLId ( _py : Python ) -> PyResult < ( String , usize ) > {
139- return convert_error ( libmathcat :: interface :: GetNavigationMathMLId ( ) ) ;
134+ return convert_error ( get_navigation_mathml_id ( ) ) ;
140135}
141136
142137#[ pyfunction]
143138/// Return the MathML associated with the current (navigation) node.
144139pub fn GetNavigationMathML ( _py : Python ) -> PyResult < ( String , usize ) > {
145- return convert_error ( libmathcat :: interface :: GetNavigationMathML ( ) ) ;
140+ return convert_error ( get_navigation_mathml ( ) ) ;
146141}
147142
148143#[ pymodule]
0 commit comments