Skip to content

Commit

Permalink
Remove usages of deprecated characterProcessing.SYMLVL_ constants and…
Browse files Browse the repository at this point in the history
… controlTypes helper functions (#12836)

Closes #12549

Summary of the issue:
characterProcessing.SYMLVL_* constants should be replaced using their equivalent SymbolLevel.* before 2022.1.
Unit testing for controlTypes helper functions needed updating for soon to be removed processNegativeStates and processPositiveStates.

Update the usages of these constants and helper functions

Testing strategy:
Search the repo for 2022 usages and noted deprecations in changes for developers.
Ensure all code deprecated for removal in 2022.1 is not used in the codebase.
  • Loading branch information
seanbudd committed Sep 13, 2021
1 parent 9f671ba commit 48f5022
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion source/NVDAHelper.py
Expand Up @@ -218,7 +218,7 @@ def handleInputCompositionEnd(result):
if curInputComposition and not result:
result=curInputComposition.compositionString.lstrip(u'\u3000 ')
if result:
speech.speakText(result,symbolLevel=characterProcessing.SYMLVL_ALL)
speech.speakText(result, symbolLevel=characterProcessing.SymbolLevel.ALL)

def handleInputCompositionStart(compositionString,selectionStart,selectionEnd,isReading):
import speech
Expand Down
7 changes: 6 additions & 1 deletion source/NVDAObjects/inputComposition.py
Expand Up @@ -72,7 +72,12 @@ def reportNewText(self,oldString,newString):
if (config.conf["keyboard"]["speakTypedCharacters"] or config.conf["keyboard"]["speakTypedWords"]):
newText=calculateInsertedChars(oldString.strip(u'\u3000'),newString.strip(u'\u3000'))
if newText:
queueHandler.queueFunction(queueHandler.eventQueue,speech.speakText,newText,symbolLevel=characterProcessing.SYMLVL_ALL)
queueHandler.queueFunction(
queueHandler.eventQueue,
speech.speakText,
newText,
symbolLevel=characterProcessing.SymbolLevel.ALL
)

def compositionUpdate(self,compositionString,selectionStart,selectionEnd,isReading,announce=True):
if isReading and not config.conf["inputComposition"]["reportReadingStringChanges"]: return
Expand Down
2 changes: 1 addition & 1 deletion source/globalCommands.py
Expand Up @@ -913,7 +913,7 @@ def script_cycleSpeechSymbolLevel(self,gesture):
if level > curLevel:
break
else:
level = characterProcessing.SYMLVL_NONE
level = characterProcessing.SymbolLevel.NONE
name = characterProcessing.SPEECH_SYMBOL_LEVEL_LABELS[level]
config.conf["speech"]["symbolLevel"] = level.value
# Translators: Reported when the user cycles through speech symbol levels
Expand Down
2 changes: 1 addition & 1 deletion source/gui/settingsDialogs.py
Expand Up @@ -4394,7 +4394,7 @@ def OnAddClick(self, evt):
pass
addedSymbol.displayName = identifier
addedSymbol.replacement = ""
addedSymbol.level = characterProcessing.SYMLVL_ALL
addedSymbol.level = characterProcessing.SymbolLevel.ALL
addedSymbol.preserve = characterProcessing.SYMPRES_NEVER
self.symbols.append(addedSymbol)
self.symbolsList.ItemCount = len(self.symbols)
Expand Down
2 changes: 1 addition & 1 deletion source/inputCore.py
Expand Up @@ -553,7 +553,7 @@ def _handleInputHelp(self, gesture, onlyLog=False):
speech.speakText(
textList[0],
reason=controlTypes.OutputReason.MESSAGE,
symbolLevel=characterProcessing.SYMLVL_ALL
symbolLevel=characterProcessing.SymbolLevel.ALL
)
for text in textList[1:]:
speech.speakMessage(text)
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_characterProcessing.py
Expand Up @@ -9,7 +9,7 @@
import unittest
import re
from characterProcessing import SpeechSymbolProcessor
from characterProcessing import SYMLVL_ALL
from characterProcessing import SymbolLevel
from characterProcessing import processSpeechSymbols as process


Expand Down Expand Up @@ -124,7 +124,7 @@ def test_multiple_group_replacement(self):
def test_engine(self):
"""Test inclusion of group replacement in engine
"""
replaced = process("fr_FR", "Le 03.04.05.", SYMLVL_ALL)
replaced = process("fr_FR", "Le 03.04.05.", SymbolLevel.ALL)
self.assertEqual(replaced, "Le 03 point 04 point 05 point.")
replaced = process("fr_FR", "Le 03/04/05.", SYMLVL_ALL)
replaced = process("fr_FR", "Le 03/04/05.", SymbolLevel.ALL)
self.assertEqual(replaced, "Le 03 barre oblique 04 barre oblique 05 point.")
5 changes: 3 additions & 2 deletions tests/unit/test_controlTypes.py
Expand Up @@ -10,6 +10,7 @@
import controlTypes
import versionInfo
from . import PlaceholderNVDAObject
from controlTypes.processAndLabelStates import _processNegativeStates, _processPositiveStates


class TestLabels(unittest.TestCase):
Expand Down Expand Up @@ -53,7 +54,7 @@ def setUp(self):

def test_positiveStates(self):
self.assertSetEqual(
controlTypes.processPositiveStates(
_processPositiveStates(
self.obj.role,
self.obj.states,
controlTypes.OutputReason.FOCUS,
Expand All @@ -64,7 +65,7 @@ def test_positiveStates(self):

def test_negativeStates(self):
self.assertSetEqual(
controlTypes.processNegativeStates(
_processNegativeStates(
self.obj.role,
self.obj.states,
controlTypes.OutputReason.FOCUS,
Expand Down

0 comments on commit 48f5022

Please sign in to comment.