Skip to content

Commit 4cdd54e

Browse files
author
preetham.ntp
committed
fix lint errors
1 parent ac07f40 commit 4cdd54e

File tree

26 files changed

+4474
-2708
lines changed

26 files changed

+4474
-2708
lines changed

Example/test.py

Lines changed: 45 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
# MathCAT add-on: generates speech, braille, and allows exploration of expressions written in MathML
2-
# The goal of this add-on is to replicate/improve on the functionality of MathPlayer which has been discontinued.
1+
# MathCAT add-on: generates speech, braille, and allows exploration of
2+
# expressions written in MathML
3+
# The goal of this add-on is to replicate/improve on the functionality of
4+
# MathPlayer which has been discontinued.
35
# Author: Neil Soiffer
4-
# Copyright: this file uses whatever GNU copyright that is required for NVDA addons
5-
# The code additionally makes use of the MathCAT library (written in Rust) which is covered by the MIT license
6+
# Copyright: this file uses whatever GNU copyright that is
7+
# required for NVDA addons
8+
# The code additionally makes use of the MathCAT library (written in Rust)
9+
# which is covered by the MIT license
610
# and also (obviously) requires external speech engines and braille drivers.
711

812

@@ -11,43 +15,49 @@
1115
# import shutil
1216
# if os.path.exists("libmathcat_py.pyd"):
1317
# os.remove("libmathcat_py.pyd")
14-
# shutil.copy("..\\target\\i686-pc-windows-msvc\\release\\libmathcat_py.dll", "libmathcat.pyd")
18+
# shutil.copy("..\\target\\i686-pc-windows-msvc\\release\\libmathcat_py.dll",
19+
# "libmathcat.pyd")
1520

1621
import libmathcat
1722

23+
1824
def SetMathCATPreferences():
19-
try:
20-
libmathcat.SetRulesDir(
21-
# this assumes the Rules dir is in the same dir a the library. Modify as needed
22-
os.path.join( os.path.dirname(os.path.abspath(__file__)), "Rules")
23-
)
24-
except Exception as e:
25-
print("problem with finding the MathCAT rules")
26-
27-
try:
28-
libmathcat.SetPreference("TTS", "none")
29-
libmathcat.SetPreference("Language", "en") # Also "id" and "vi"
30-
libmathcat.SetPreference("SpeechStyle", "SimpleSpeak") # Also "ClearSpeak"
31-
libmathcat.SetPreference("Verbosity", "Verbose") # also terse "Terse"/"Medium"
32-
libmathcat.SetPreference("CapitalLetters_UseWord", "true") # if "true", X => "cap x"
33-
except Exception as e:
34-
print("problem with setting a preference")
25+
try:
26+
libmathcat.SetRulesDir(
27+
# this assumes the Rules dir is in the same dir a the library.
28+
# Modify as needed
29+
os.path.join(os.path.dirname(os.path.abspath(__file__)), "Rules")
30+
)
31+
except Exception as e:
32+
print(e, "problem with finding the MathCAT rules")
33+
34+
try:
35+
libmathcat.SetPreference("TTS", "none")
36+
libmathcat.SetPreference("Language", "en") # Also "id" and "vi"
37+
libmathcat.SetPreference("SpeechStyle", "SimpleSpeak") # Also "ClearSpeak" # noqa
38+
libmathcat.SetPreference("Verbosity", "Verbose") # also terse "Terse"/"Medium" # noqa
39+
libmathcat.SetPreference(
40+
"CapitalLetters_UseWord", "true"
41+
) # if "true", X => "cap x"
42+
except Exception as e:
43+
print(e, "problem with setting a preference")
44+
3545

3646
def SetMathMLForMathCAT(mathml: str):
37-
try:
38-
libmathcat.SetMathML(mathml)
39-
except Exception as e:
40-
print("problem with SetMathML")
47+
try:
48+
libmathcat.SetMathML(mathml)
49+
except Exception as e:
50+
print(e, "problem with SetMathML")
4151

42-
def GetSpeech():
43-
try:
44-
return libmathcat.GetSpokenText()
45-
except Exception as e:
46-
return "problem with getting speech for MathML"
4752

53+
def GetSpeech():
54+
try:
55+
return libmathcat.GetSpokenText()
56+
except Exception as e:
57+
return e, "problem with getting speech for MathML"
4858

4959

50-
SetMathCATPreferences() # you only need to this once
60+
SetMathCATPreferences() # you only need to this once
5161
print("Using MathCAT version '{}'".format(libmathcat.GetVersion()))
5262

5363
mathml = "<math><mfrac> <mn>1</mn> <mi>X</mi> </mfrac> </math>"
@@ -62,14 +72,16 @@ def GetSpeech():
6272
SetMathMLForMathCAT(mathml)
6373
print("MathML: {}\nSpeech: '{}'".format(mathml, GetSpeech()))
6474

65-
mathml = "<math><msup intent='transpose:postfix($x)'> <mi arg='x'>x</mi> <mi>T</mi> </msup> </math>"
75+
mathml = "<math><msup intent='transpose:postfix($x)'> <mi arg='x'>x</mi><mi>T \
76+
</mi> </msup> </math>"
6677
SetMathMLForMathCAT(mathml)
6778
print("MathML: {}\nSpeech: '{}'".format(mathml, GetSpeech()))
6879

6980
mathml = "<math><mrow intent='_(x, $op)'><mo arg='op'>!</mo></mrow></math>"
7081
SetMathMLForMathCAT(mathml)
7182
print("MathML: {}\nSpeech: '{}'".format(mathml, GetSpeech()))
7283

73-
mathml = "<math intent=':structure'><mrow><mo>(</mo><mfrac linethickness='0'><mn arg='n'>7</mn><mn arg='m'>3</mn></mfrac><mo>)</mo></mrow></math>"
84+
mathml = "<math intent=':structure'><mrow><mo>(</mo><mfrac linethickness='0'> \
85+
<mn arg='n'>7</mn><mn arg='m'>3</mn></mfrac><mo>)</mo></mrow></math>"
7486
SetMathMLForMathCAT(mathml)
7587
print("MathML: {}\nSpeech (no inference): '{}'".format(mathml, GetSpeech()))

0 commit comments

Comments
 (0)