Skip to content

Commit

Permalink
Remove backwards compat aliases from PR 10593 (#12195)
Browse files Browse the repository at this point in the history
Removes code provided for backwards compatibility in PR #10593

### Summary of the issue:

PR #10593 introduced `speech.speakWithoutPauses ` as an alias for `speech._speakWithoutPauses.speakWithoutPauses` and `speech.re_last_pause` as an alias for `speech._speakWithoutPauses.re_last_pause` for backwards compatibility. Since 2021.1 is going to be backwards compatibility breaking release it makes sense to remove these.

### Description of how this pull request fixes the issue:

These aliases are removed and their usages are replaces with `speech.SpeechWithoutPauses(speakFunc=speech.speak).speakWithoutPauses` and `speech.SpeechWithoutPauses.re_last_pause` respectively.
  • Loading branch information
lukaszgo1 committed Mar 22, 2021
1 parent abdf77e commit f2a734b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
12 changes: 8 additions & 4 deletions source/sayAllHandler.py
Expand Up @@ -16,6 +16,10 @@

from speech.commands import CallbackCommand, EndUtteranceCommand


speakWithoutPauses = speech.SpeechWithoutPauses(speakFunc=speech.speak).speakWithoutPauses


CURSOR_CARET = 0
CURSOR_REVIEW = 1

Expand Down Expand Up @@ -150,7 +154,7 @@ def nextLine(self):
if isinstance(self.reader.obj, textInfos.DocumentWithPageTurns):
# Once the last line finishes reading, try turning the page.
cb = CallbackCommand(self.turnPage, name="say-all:turnPage")
speech.speakWithoutPauses([cb, EndUtteranceCommand()])
speakWithoutPauses([cb, EndUtteranceCommand()])
else:
self.finish()
return
Expand Down Expand Up @@ -182,7 +186,7 @@ def _onLineReached(obj=self.reader.obj, state=state):
seq = list(speech._flattenNestedSequences(speechGen))
seq.insert(0, cb)
# Speak the speech sequence.
spoke = speech.speakWithoutPauses(seq)
spoke = speakWithoutPauses(seq)
# Update the textInfo state ready for when speaking the next line.
self.speakTextInfoState = state.copy()

Expand All @@ -204,7 +208,7 @@ def _onLineReached(obj=self.reader.obj, state=state):
else:
# We don't want to buffer too much.
# Force speech. lineReached will resume things when speech catches up.
speech.speakWithoutPauses(None)
speakWithoutPauses(None)
# The first buffered line has now started speaking.
self.numBufferedLines -= 1

Expand Down Expand Up @@ -241,7 +245,7 @@ def finish(self):
# we might switch synths too early and truncate the final speech.
# We do this by putting a CallbackCommand at the start of a new utterance.
cb = CallbackCommand(self.stop, name="say-all:stop")
speech.speakWithoutPauses([
speakWithoutPauses([
EndUtteranceCommand(),
cb,
EndUtteranceCommand()
Expand Down
6 changes: 0 additions & 6 deletions source/speech/__init__.py
Expand Up @@ -51,7 +51,6 @@
Generator,
Union,
Callable,
Iterator,
Tuple,
)
from logHandler import log
Expand Down Expand Up @@ -466,7 +465,6 @@ def getObjectSpeech( # noqa: C901
reason: OutputReason = OutputReason.QUERY,
_prefixSpeechCommand: Optional[SpeechCommand] = None,
):
from NVDAObjects import NVDAObjectTextInfo
role=obj.role
# Choose when we should report the content of this object's textInfo, rather than just the object's value
import browseMode
Expand Down Expand Up @@ -2538,10 +2536,6 @@ def _getSpeech(

_speakWithoutPauses = SpeechWithoutPauses(speakFunc=speak)

#: Alias for class SpeakWithoutPauses.speakWithoutPauses. Kept for backwards compatibility
speakWithoutPauses = _speakWithoutPauses.speakWithoutPauses
#: Kept for backwards compatibility.
re_last_pause = _speakWithoutPauses.re_last_pause

#: The singleton _SpeechManager instance used for speech functions.
#: @type: L{manager.SpeechManager}
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_SpeechWithoutPauses.py
Expand Up @@ -10,7 +10,7 @@

from speech.types import SpeechSequence
from speech.commands import EndUtteranceCommand, LangChangeCommand, CallbackCommand
from speech import re_last_pause, SpeechWithoutPauses
from speech import SpeechWithoutPauses
from logHandler import log


Expand Down Expand Up @@ -89,7 +89,7 @@ def old_speakWithoutPauses( # noqa: C901
for index in range(len(speechSequence) - 1, -1, -1):
item = speechSequence[index]
if isinstance(item, str):
m = re_last_pause.match(item)
m = SpeechWithoutPauses.re_last_pause.match(item)
if m:
before, after = m.groups()
if after:
Expand Down
2 changes: 2 additions & 0 deletions user_docs/en/changes.t2t
Expand Up @@ -82,6 +82,8 @@ What's New in NVDA
- `autoSettingsUtils.driverSetting` classes are removed from `driverHandler` - please use them from `autoSettingUtils.driverSetting`. (#12168)
- `autoSettingsUtils.utils` classes are removed from `driverHandler` - please use them from `autoSettingUtils.utils`. (#12168)
- Support of `TextInfo`s that do not inherit from `contentRecog.BaseContentRecogTextInfo` is removed. (#12157)
- `speech.speakWithoutPauses` has been removed - please use `speech.SpeechWithoutPauses(speakFunc=speech.speak).speakWithoutPauses` instead. (#12195)
- `speech.re_last_pause` has been removed - please use `speech.SpeechWithoutPauses.re_last_pause` instead. (#12195)


= 2020.4 =
Expand Down

0 comments on commit f2a734b

Please sign in to comment.