Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the config using the integer value of a SymbolLevel enum member #12636

Merged
merged 3 commits into from Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 21 additions & 21 deletions source/characterProcessing.py
Expand Up @@ -127,7 +127,7 @@ def getCharacterDescription(locale,character):


# Speech symbol levels
class SYMLVL(IntEnum):
class SymbolLevel(IntEnum):
NONE = 0
SOME = 100
MOST = 200
Expand All @@ -137,28 +137,28 @@ class SYMLVL(IntEnum):


# The following SYMLVL_ constants are deprecated in #11856 but remain to maintain backwards compatibility.
# Remove these in 2022.1 and replace instances using them with the SYMLVL IntEnum.
# Remove these in 2022.1 and replace instances using them with the SymbolLevel IntEnum.
if version_year < 2022:
SYMLVL_NONE = SYMLVL.NONE
SYMLVL_SOME = SYMLVL.SOME
SYMLVL_MOST = SYMLVL.MOST
SYMLVL_ALL = SYMLVL.ALL
SYMLVL_CHAR = SYMLVL.CHAR
SYMLVL_NONE = SymbolLevel.NONE
SYMLVL_SOME = SymbolLevel.SOME
SYMLVL_MOST = SymbolLevel.MOST
SYMLVL_ALL = SymbolLevel.ALL
SYMLVL_CHAR = SymbolLevel.CHAR

SPEECH_SYMBOL_LEVEL_LABELS = {
# Translators: The level at which the given symbol will be spoken.
SYMLVL.NONE: pgettext("symbolLevel", "none"),
SymbolLevel.NONE: pgettext("symbolLevel", "none"),
# Translators: The level at which the given symbol will be spoken.
SYMLVL.SOME: pgettext("symbolLevel", "some"),
SymbolLevel.SOME: pgettext("symbolLevel", "some"),
# Translators: The level at which the given symbol will be spoken.
SYMLVL.MOST: pgettext("symbolLevel", "most"),
SymbolLevel.MOST: pgettext("symbolLevel", "most"),
# Translators: The level at which the given symbol will be spoken.
SYMLVL.ALL: pgettext("symbolLevel", "all"),
SymbolLevel.ALL: pgettext("symbolLevel", "all"),
# Translators: The level at which the given symbol will be spoken.
SYMLVL.CHAR: pgettext("symbolLevel", "character"),
SymbolLevel.CHAR: pgettext("symbolLevel", "character"),
}
CONFIGURABLE_SPEECH_SYMBOL_LEVELS = (SYMLVL.NONE, SYMLVL.SOME, SYMLVL.MOST, SYMLVL.ALL)
SPEECH_SYMBOL_LEVELS = CONFIGURABLE_SPEECH_SYMBOL_LEVELS + (SYMLVL.CHAR,)
CONFIGURABLE_SPEECH_SYMBOL_LEVELS = (SymbolLevel.NONE, SymbolLevel.SOME, SymbolLevel.MOST, SymbolLevel.ALL)
SPEECH_SYMBOL_LEVELS = CONFIGURABLE_SPEECH_SYMBOL_LEVELS + (SymbolLevel.CHAR,)

# Speech symbol preserve modes
SYMPRES_NEVER = 0
Expand Down Expand Up @@ -269,11 +269,11 @@ def _loadSymbolField(self, input, inputMap=None):
}
IDENTIFIER_ESCAPES_OUTPUT = {v: k for k, v in IDENTIFIER_ESCAPES_INPUT.items()}
LEVEL_INPUT = {
"none": SYMLVL.NONE,
"some": SYMLVL.SOME,
"most": SYMLVL.MOST,
"all": SYMLVL.ALL,
"char": SYMLVL.CHAR,
"none": SymbolLevel.NONE,
"some": SymbolLevel.SOME,
"most": SymbolLevel.MOST,
"all": SymbolLevel.ALL,
"char": SymbolLevel.CHAR,
}
LEVEL_OUTPUT = {v:k for k, v in LEVEL_INPUT.items()}
PRESERVE_INPUT = {
Expand Down Expand Up @@ -499,7 +499,7 @@ def __init__(self, locale):
pass
continue
if symbol.level is None:
symbol.level = SYMLVL.ALL
symbol.level = SymbolLevel.ALL
if symbol.preserve is None:
symbol.preserve = SYMPRES_NEVER
if symbol.displayName is None:
Expand Down Expand Up @@ -676,7 +676,7 @@ def isBuiltin(self, symbolIdentifier):
_localeSpeechSymbolProcessors = LocaleDataMap(SpeechSymbolProcessor)


def processSpeechSymbols(locale: str, text: str, level: SYMLVL):
def processSpeechSymbols(locale: str, text: str, level: SymbolLevel):
"""Process some text, converting symbols according to desired pronunciation.
@param locale: The locale of the text.
@param text: The text to process.
Expand Down
2 changes: 1 addition & 1 deletion source/globalCommands.py
Expand Up @@ -889,7 +889,7 @@ def script_cycleSpeechSymbolLevel(self,gesture):
else:
level = characterProcessing.SYMLVL_NONE
name = characterProcessing.SPEECH_SYMBOL_LEVEL_LABELS[level]
config.conf["speech"]["symbolLevel"] = level
config.conf["speech"]["symbolLevel"] = level.value
# Translators: Reported when the user cycles through speech symbol levels
# which determine what symbols are spoken.
# %s will be replaced with the symbol level; e.g. none, some, most and all.
Expand Down
2 changes: 1 addition & 1 deletion source/gui/settingsDialogs.py
Expand Up @@ -1592,7 +1592,7 @@ def onSave(self):
config.conf["speech"]["autoDialectSwitching"] = self.autoDialectSwitchingCheckbox.IsChecked()
config.conf["speech"]["symbolLevel"] = characterProcessing.CONFIGURABLE_SPEECH_SYMBOL_LEVELS[
self.symbolLevelList.GetSelection()
]
].value
config.conf["speech"]["symbolLevelWordAll"] = self.symbolLevelWordAll.IsChecked()
config.conf["speech"]["trustVoiceLanguage"] = self.trustVoiceLanguageCheckbox.IsChecked()
currentIncludeCLDR = config.conf["speech"]["includeCLDR"]
Expand Down
6 changes: 3 additions & 3 deletions source/speech/speech.py
Expand Up @@ -1126,12 +1126,12 @@ def speakTextInfo(
)

speechGen = GeneratorWithReturn(speechGen)
symbolLevel: Optional[characterProcessing.SYMLVL] = None
symbolLevel: Optional[characterProcessing.SymbolLevel] = None
if unit == textInfos.UNIT_CHARACTER:
symbolLevel = characterProcessing.SYMLVL.ALL
symbolLevel = characterProcessing.SymbolLevel.ALL
elif unit == textInfos.UNIT_WORD:
if config.conf["speech"]["symbolLevelWordAll"]:
symbolLevel = characterProcessing.SYMLVL.ALL
symbolLevel = characterProcessing.SymbolLevel.ALL
for seq in speechGen:
speak(seq, symbolLevel=symbolLevel, priority=priority)
return speechGen.returnValue
Expand Down
2 changes: 1 addition & 1 deletion user_docs/en/changes.t2t
Expand Up @@ -42,7 +42,7 @@ This can be toggled in the Preferences dialog or with a new (unassigned) command


== Changes for Developers ==
- ``characterProcessing.SYMLVL_*`` constants should be replaced using their equivalent ``SYMLVL.*`` before 2022.1. (#11856)
- ``characterProcessing.SYMLVL_*`` constants should be replaced using their equivalent ``SymbolLevel.*`` before 2022.1. (#11856, #12636)
- ``controlTypes`` has been split up into various submodules, symbols marked for deprecation must be replaced before 2022.1. (#12510)
- ``ROLE_*`` and ``STATE_*`` constants should be replaced to their equivalent ``Role.*`` and ``State.*``.
- ``roleLabels``, ``stateLabels`` and ``negativeStateLabels`` have been deprecated, usages such as ``roleLabels[ROLE_*]`` should be replaced to their equivalent ``Role.*.displayString`` or ``State.*.negativeDisplayString``.
Expand Down