Skip to content

Commit 3aa153d

Browse files
authored
Changed method names to lowerCamelCase (#6)
The PR changes all of the names of methods in MathCAT.py, MathCATPreferences.py, and MathCATgui.py to lowerCamelCase
1 parent 8661689 commit 3aa153d

File tree

3 files changed

+57
-57
lines changed

3 files changed

+57
-57
lines changed

addon/globalPlugins/MathCAT/MathCAT.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def getLanguageToUse(mathMl: str = "") -> str:
110110
return language
111111

112112

113-
def ConvertSSMLTextForNVDA(text: str) -> list:
113+
def convertSSMLTextForNVDA(text: str) -> list:
114114
"""Change the SSML in the text into NVDA's command structure.
115115
The environment is examined to determine whether a language switch is needed"""
116116
# MathCAT's default rate is 180 wpm.
@@ -231,7 +231,7 @@ def reportFocus(self):
231231
getSynth()._set_rate(_synthesizerRate)
232232
try:
233233
text = libmathcat.DoNavigateCommand("ZoomIn")
234-
speech.speak(ConvertSSMLTextForNVDA(text))
234+
speech.speak(convertSSMLTextForNVDA(text))
235235
except Exception as e:
236236
log.exception(e)
237237
# Translators: this message directs users to look in the log file
@@ -307,7 +307,7 @@ def script_navigate(self, gesture: KeyboardInputGesture):
307307
False,
308308
)
309309
# log.info(f"Navigate speech for {gesture.vkCode}/(s={'shift' in modNames}, c={'control' in modNames}): '{text}'")
310-
speech.speak(ConvertSSMLTextForNVDA(text))
310+
speech.speak(convertSSMLTextForNVDA(text))
311311
except Exception as e:
312312
log.exception(e)
313313
# Translators: this message directs users to look in the log file
@@ -515,11 +515,11 @@ def getSpeechForMathMl(self, mathml: str):
515515
if self._addSounds():
516516
return (
517517
[BeepCommand(800, 25)]
518-
+ ConvertSSMLTextForNVDA(libmathcat.GetSpokenText())
518+
+ convertSSMLTextForNVDA(libmathcat.GetSpokenText())
519519
+ [BeepCommand(600, 15)]
520520
)
521521
else:
522-
return ConvertSSMLTextForNVDA(libmathcat.GetSpokenText())
522+
return convertSSMLTextForNVDA(libmathcat.GetSpokenText())
523523

524524
except Exception as e:
525525
log.exception(e)

addon/globalPlugins/MathCAT/MathCATPreferences.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import addonHandler
1212
from logHandler import log # logging
1313
from typing import List, Dict, Union, Callable
14-
from .MathCAT import ConvertSSMLTextForNVDA
14+
from .MathCAT import convertSSMLTextForNVDA
1515
from speech import speak
1616
from zipfile import ZipFile
1717

@@ -72,8 +72,8 @@ def __init__(self, parent):
7272
self._listBoxPreferencesTopic.SetSelection(0)
7373
userPreferences["NVDAAddOn"] = {"LastCategory": "0"}
7474
# populate the languages and braille codes
75-
UserInterface.GetLanguages(self)
76-
UserInterface.GetBrailleCodes(self)
75+
UserInterface.getLanguages(self)
76+
UserInterface.getBrailleCodes(self)
7777
# set the ui items to match the preferences
7878
UserInterface.setUIValues(self)
7979

@@ -88,7 +88,7 @@ def pathToBrailleFolder():
8888
return os.path.join(os.path.dirname(os.path.abspath(__file__)), "Rules", "Braille")
8989

9090
@staticmethod
91-
def LanguagesDict() -> Dict[str, str]:
91+
def languagesDict() -> Dict[str, str]:
9292
languages = {
9393
"aa": "Afar",
9494
"ab": "Аҧсуа",
@@ -291,13 +291,13 @@ def getRulesFiles(
291291

292292
return ruleFiles
293293

294-
def GetLanguages(self):
294+
def getLanguages(self):
295295
def addRegionalLanguages(subDir: str, language: str) -> List[str]:
296296
# the language variants are in folders named using ISO 3166-1 alpha-2
297297
# codes https://en.wikipedia.org/wiki/ISO_3166-2
298298
# check if there are language variants in the language folder
299299
if subDir != "SharedRules":
300-
languagesDict = UserInterface.LanguagesDict()
300+
languagesDict = UserInterface.languagesDict()
301301
# add to the listbox the text for this language variant together with the code
302302
regionalCode = language + "-" + subDir.upper()
303303
if languagesDict.get(regionalCode, "missing") != "missing":
@@ -310,7 +310,7 @@ def addRegionalLanguages(subDir: str, language: str) -> List[str]:
310310
return []
311311

312312
# initialise the language list
313-
languagesDict = UserInterface.LanguagesDict()
313+
languagesDict = UserInterface.languagesDict()
314314
# clear the language names in the dialog
315315
self._choiceLanguage.Clear()
316316
# Translators: menu item -- use the language of the voice chosen in the NVDA speech settings dialog
@@ -331,12 +331,12 @@ def addRegionalLanguages(subDir: str, language: str) -> List[str]:
331331
else:
332332
self._choiceLanguage.Append(language + " (" + language + ")")
333333

334-
def GetLanguageCode(self):
334+
def getLanguageCode(self):
335335
lang_selection = self._choiceLanguage.GetStringSelection()
336336
lang_code = lang_selection[lang_selection.find("(") + 1 : lang_selection.find(")")]
337337
return lang_code
338338

339-
def GetSpeechStyles(self, thisSpeechStyle: str):
339+
def getSpeechStyles(self, thisSpeechStyle: str):
340340
"""Get all the speech styles for the current language.
341341
This sets the SpeechStyles dialog entry"""
342342
from speech import getCurrentLanguage
@@ -370,7 +370,7 @@ def getSpeechStyleFromDirectory(dir: str, lang: str) -> list[str]:
370370
# clear the SpeechStyle choices
371371
self._choiceSpeechStyle.Clear()
372372
# get the currently selected language code
373-
languageCode = UserInterface.GetLanguageCode(self)
373+
languageCode = UserInterface.getLanguageCode(self)
374374

375375
if languageCode == "Auto":
376376
# list the speech styles for the current voice rather than have none listed
@@ -402,7 +402,7 @@ def getSpeechStyleFromDirectory(dir: str, lang: str) -> list[str]:
402402
# that didn't work, choose the first in the list
403403
self._choiceSpeechStyle.SetSelection(0)
404404

405-
def GetBrailleCodes(self):
405+
def getBrailleCodes(self):
406406
# initialise the braille code list
407407
self._choiceBrailleMathCode.Clear()
408408
# populate the available braille codes in the dialog
@@ -438,7 +438,7 @@ def setUIValues(self):
438438
self._choiceLanguage.SetSelection(0)
439439
try:
440440
# now get the available SpeechStyles from the folder structure and set to the preference setting is possible
441-
self.GetSpeechStyles(str(userPreferences["Speech"]["SpeechStyle"]))
441+
self.getSpeechStyles(str(userPreferences["Speech"]["SpeechStyle"]))
442442
except Exception as e:
443443
log.exception(f"MathCAT: An exception occurred in set_ui_values (getting SpeechStyle): {e}")
444444
self._choiceSpeechStyle.Append(
@@ -511,7 +511,7 @@ def getUIValues(self):
511511
global userPreferences
512512
# read the values from the UI and update the user preferences dictionary
513513
userPreferences["Speech"]["Impairment"] = Speech_Impairment[self._choiceImpairment.GetSelection()]
514-
userPreferences["Speech"]["Language"] = self.GetLanguageCode()
514+
userPreferences["Speech"]["Language"] = self.getLanguageCode()
515515
userPreferences["Other"]["DecimalSeparator"] = Speech_DecimalSeparator[
516516
self._choiceDecimalSeparator.GetSelection()
517517
]
@@ -695,17 +695,17 @@ def writeUserPreferences():
695695
# write values to the user preferences file, NOT the default
696696
yaml.dump(userPreferences, stream=f, allow_unicode=True)
697697

698-
def OnRelativeSpeedChanged(self, event):
698+
def onRelativeSpeedChanged(self, event):
699699
rate = self._sliderRelativeSpeed.GetValue()
700700
# Translators: this is a test string that is spoken. Only translate "the square root of x squared plus y squared"
701701
text = _("<prosody rate='XXX%'>the square root of x squared plus y squared</prosody>").replace(
702702
"XXX",
703703
str(rate),
704704
1,
705705
)
706-
speak(ConvertSSMLTextForNVDA(text))
706+
speak(convertSSMLTextForNVDA(text))
707707

708-
def OnPauseFactorChanged(self, event):
708+
def onPauseFactorChanged(self, event):
709709
rate = self._sliderRelativeSpeed.GetValue()
710710
pfSlider = self._sliderPauseFactor.GetValue()
711711
pauseFactor = (
@@ -730,44 +730,44 @@ def OnPauseFactorChanged(self, event):
730730
pause_factor_300=300 * pauseFactor // 100,
731731
pause_factor_600=600 * pauseFactor // 100,
732732
)
733-
speak(ConvertSSMLTextForNVDA(text))
733+
speak(convertSSMLTextForNVDA(text))
734734

735-
def OnClickOK(self, event):
735+
def onClickOK(self, event):
736736
UserInterface.getUIValues(self)
737737
UserInterface.writeUserPreferences()
738738
self.Destroy()
739739

740-
def OnClickCancel(self, event):
740+
def onClickCancel(self, event):
741741
self.Destroy()
742742

743-
def OnClickApply(self, event):
743+
def onClickApply(self, event):
744744
UserInterface.getUIValues(self)
745745
UserInterface.writeUserPreferences()
746746

747-
def OnClickReset(self, event):
747+
def onClickReset(self, event):
748748
UserInterface.loadDefaultPreferences()
749749
UserInterface.validateUserPreferences()
750750
UserInterface.setUIValues(self)
751751

752-
def OnClickHelp(self, event):
752+
def onClickHelp(self, event):
753753
webbrowser.open("https://nsoiffer.github.io/MathCAT/users.html")
754754

755-
def OnListBoxCategories(self, event):
755+
def onListBoxCategories(self, event):
756756
# the category changed, now show the appropriate dialogue page
757757
self._simplebookPanelsCategories.SetSelection(self._listBoxPreferencesTopic.GetSelection())
758758

759-
def OnLanguage(self, event):
759+
def onLanguage(self, event):
760760
# the language changed, get the SpeechStyles for the new language
761-
UserInterface.GetSpeechStyles(self, self._choiceSpeechStyle.GetStringSelection())
761+
UserInterface.getSpeechStyles(self, self._choiceSpeechStyle.GetStringSelection())
762762

763-
def MathCATPreferencesDialogOnCharHook(self, event: wx.KeyEvent):
763+
def mathCATPreferencesDialogOnCharHook(self, event: wx.KeyEvent):
764764
# designed choice is that Enter is the same as clicking OK, and Escape is the same as clicking Cancel
765765
keyCode = event.GetKeyCode()
766766
if keyCode == wx.WXK_ESCAPE:
767-
UserInterface.OnClickCancel(self, event)
767+
UserInterface.onClickCancel(self, event)
768768
return
769769
if keyCode == wx.WXK_RETURN:
770-
UserInterface.OnClickOK(self, event)
770+
UserInterface.onClickOK(self, event)
771771
if keyCode == wx.WXK_TAB:
772772
if event.GetModifiers() == wx.MOD_CONTROL:
773773
# cycle the category forward
@@ -776,7 +776,7 @@ def MathCATPreferencesDialogOnCharHook(self, event: wx.KeyEvent):
776776
newCategory = 0
777777
self._listBoxPreferencesTopic.SetSelection(newCategory)
778778
# update the ui to show the new page
779-
UserInterface.OnListBoxCategories(self, event)
779+
UserInterface.onListBoxCategories(self, event)
780780
# set the focus into the category list box
781781
self._listBoxPreferencesTopic.SetFocus()
782782
# jump out so the tab key is not processed
@@ -788,7 +788,7 @@ def MathCATPreferencesDialogOnCharHook(self, event: wx.KeyEvent):
788788
newCategory = 2
789789
self._listBoxPreferencesTopic.SetSelection(newCategory)
790790
# update the ui to show the new page
791-
UserInterface.OnListBoxCategories(self, event)
791+
UserInterface.onListBoxCategories(self, event)
792792
# update the ui to show the new page
793793
self._listBoxPreferencesTopic.SetFocus()
794794
# jump out so the tab key is not processed

addon/globalPlugins/MathCAT/MathCATgui.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -809,54 +809,54 @@ def __init__(self, parent):
809809
self.Centre(wx.BOTH)
810810

811811
# Connect Events
812-
self.Bind(wx.EVT_CHAR_HOOK, self.MathCATPreferencesDialogOnCharHook)
813-
self.Bind(wx.EVT_KEY_UP, self.MathCATPreferencesDialogOnKeyUp)
814-
self._listBoxPreferencesTopic.Bind(wx.EVT_LISTBOX, self.OnListBoxCategories)
815-
self._choiceLanguage.Bind(wx.EVT_CHOICE, self.OnLanguage)
812+
self.Bind(wx.EVT_CHAR_HOOK, self.mathCATPreferencesDialogOnCharHook)
813+
self.Bind(wx.EVT_KEY_UP, self.mathCATPreferencesDialogOnKeyUp)
814+
self._listBoxPreferencesTopic.Bind(wx.EVT_LISTBOX, self.onListBoxCategories)
815+
self._choiceLanguage.Bind(wx.EVT_CHOICE, self.onLanguage)
816816
self._sliderRelativeSpeed.Bind(
817817
wx.EVT_SCROLL_CHANGED,
818-
self.OnRelativeSpeedChanged,
818+
self.onRelativeSpeedChanged,
819819
)
820-
self._sliderPauseFactor.Bind(wx.EVT_SCROLL_CHANGED, self.OnPauseFactorChanged)
821-
self._buttonOK.Bind(wx.EVT_BUTTON, self.OnClickOK)
822-
self._buttonCancel.Bind(wx.EVT_BUTTON, self.OnClickCancel)
823-
self._buttonApply.Bind(wx.EVT_BUTTON, self.OnClickApply)
824-
self._buttonReset.Bind(wx.EVT_BUTTON, self.OnClickReset)
825-
self._buttonHelp.Bind(wx.EVT_BUTTON, self.OnClickHelp)
820+
self._sliderPauseFactor.Bind(wx.EVT_SCROLL_CHANGED, self.onPauseFactorChanged)
821+
self._buttonOK.Bind(wx.EVT_BUTTON, self.onClickOK)
822+
self._buttonCancel.Bind(wx.EVT_BUTTON, self.onClickCancel)
823+
self._buttonApply.Bind(wx.EVT_BUTTON, self.onClickApply)
824+
self._buttonReset.Bind(wx.EVT_BUTTON, self.onClickReset)
825+
self._buttonHelp.Bind(wx.EVT_BUTTON, self.onClickHelp)
826826

827827
def __del__(self):
828828
pass
829829

830830
# Virtual event handlers, override them in your derived class
831-
def MathCATPreferencesDialogOnCharHook(self, event):
831+
def mathCATPreferencesDialogOnCharHook(self, event):
832832
event.Skip()
833833

834-
def MathCATPreferencesDialogOnKeyUp(self, event):
834+
def mathCATPreferencesDialogOnKeyUp(self, event):
835835
event.Skip()
836836

837-
def OnListBoxCategories(self, event):
837+
def onListBoxCategories(self, event):
838838
event.Skip()
839839

840-
def OnLanguage(self, event):
840+
def onLanguage(self, event):
841841
event.Skip()
842842

843-
def OnRelativeSpeedChanged(self, event):
843+
def onRelativeSpeedChanged(self, event):
844844
event.Skip()
845845

846-
def OnPauseFactorChanged(self, event):
846+
def onPauseFactorChanged(self, event):
847847
event.Skip()
848848

849-
def OnClickOK(self, event):
849+
def onClickOK(self, event):
850850
event.Skip()
851851

852-
def OnClickCancel(self, event):
852+
def onClickCancel(self, event):
853853
event.Skip()
854854

855-
def OnClickApply(self, event):
855+
def onClickApply(self, event):
856856
event.Skip()
857857

858-
def OnClickReset(self, event):
858+
def onClickReset(self, event):
859859
event.Skip()
860860

861-
def OnClickHelp(self, event):
861+
def onClickHelp(self, event):
862862
event.Skip()

0 commit comments

Comments
 (0)