Skip to content

Commit

Permalink
Merge 3b0022f into 424afaf
Browse files Browse the repository at this point in the history
  • Loading branch information
seanbudd authored Jun 14, 2022
2 parents 424afaf + 3b0022f commit 70f38a5
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 28 deletions.
14 changes: 8 additions & 6 deletions source/appModuleHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __getattr__(attrName: str) -> Any:
since add-ons are initialized before `appModuleHandler`
and when `appModuleHandler` was not yet initialized the variable was set to `None`.
"""
if attrName == "NVDAProcessID":
if attrName == "NVDAProcessID" and globalVars._useDeprecatedAPI:
log.warning("appModuleHandler.NVDAProcessID is deprecated, use globalVars.appPid instead.")
if initialize._alreadyInitialized:
return globalVars.appPid
Expand All @@ -112,12 +112,14 @@ def _warnDeprecatedAliasAppModule() -> None:
except KeyError:
raise RuntimeError("This function can be executed only inside an alias App Module.") from None
else:
log.warning(
(
f"Importing from appModules.{currModName} is deprecated,"
f" you should import from appModules.{replacementModName}."
)
importFailMsg = (
f"Importing appModules.{currModName} is deprecated,"
f" instead import appModules.{replacementModName}."
)
if globalVars._useDeprecatedAPI:
log.warning(importFailMsg)
else:
raise ModuleNotFoundError(importFailMsg)


def registerExecutableWithAppModule(executableName: str, appModName: str) -> None:
Expand Down
10 changes: 3 additions & 7 deletions source/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
For the latter two actions, one can perform actions prior to and/or after they take place.
"""


from buildVersion import version_year
from enum import Enum
import globalVars
import winreg
Expand Down Expand Up @@ -88,17 +86,15 @@ class RegistryKey(str, Enum):
"""


if version_year < 2023:
if globalVars._useDeprecatedAPI:
RUN_REGKEY = RegistryKey.RUN.value
"""
Deprecated, for removal in 2023.
Use L{RegistryKey.RUN} instead.
Deprecated, use L{RegistryKey.RUN} instead.
"""

NVDA_REGKEY = RegistryKey.NVDA.value
"""
Deprecated, for removal in 2023.
Use L{RegistryKey.NVDA} instead.
Deprecated, use L{RegistryKey.NVDA} instead.
"""


Expand Down
13 changes: 6 additions & 7 deletions source/easeOfAccess.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
"""Utilities for working with the Windows Ease of Access Center.
"""

from buildVersion import version_year
from enum import Enum, IntEnum
from typing import List

import globalVars
from logHandler import log
import winreg
import winUser
Expand All @@ -32,20 +33,18 @@ class AutoStartContext(IntEnum):
AFTER_LOGON = winreg.HKEY_CURRENT_USER


if version_year < 2023:
if globalVars._useDeprecatedAPI:
ROOT_KEY = RegistryKey.ROOT.value
"""
Deprecated, for removal in 2023.
Use L{RegistryKey.ROOT} instead.
Deprecated, use L{RegistryKey.ROOT} instead.
"""

APP_KEY_NAME = _APP_KEY_NAME
"""Deprecated, for removal in 2023"""
"""Deprecated for removal"""

APP_KEY_PATH = RegistryKey.APP.value
"""
Deprecated, for removal in 2023.
Use L{RegistryKey.APP} instead.
Deprecated, use L{RegistryKey.APP} instead.
"""


Expand Down
12 changes: 12 additions & 0 deletions source/globalVars.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,15 @@ class DefaultAppArgs(argparse.Namespace):
appPid: int = 0
"""The process ID of NVDA itself.
"""

_useDeprecatedAPI: bool = True
"""
Used for marking code as deprecated.
This should never be False in released code.
Making this False may be useful for testing if code
is compliant without using deprecated APIs.
Note that deprecated code may be imported at runtime,
and as such, this value cannot be changed at runtime
to test compliance.
"""
6 changes: 2 additions & 4 deletions source/gui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,12 @@
import speechViewer
import winUser
import api
from buildVersion import version_year


if version_year < 2023:
if globalVars._useDeprecatedAPI:
def quit():
"""
Deprecated, for removal in 2023.1.
Use `wx.CallAfter(mainFrame.onExitCommand, None)` directly instead.
Deprecated, use `wx.CallAfter(mainFrame.onExitCommand, None)` directly instead.
"""
log.debugWarning("Deprecated function called: gui.quit", stack_info=True)
wx.CallAfter(mainFrame.onExitCommand, None)
Expand Down
7 changes: 3 additions & 4 deletions user_docs/en/changes.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,11 @@ Please test the new API and provide feedback.
For add-on authors, please open a GitHub issue if these changes stop the API from meeting your needs.


- ``appModuleHandler.NVDAProcessID`` is deprecated - use ``globalVars.appPid`` instead. (#13646)
- ``gui.quit`` has been deprecated for removal in 2023.1. (#13498)
- Use ``wx.CallAfter(mainFrame.onExitCommand, None)`` directly instead.
- ``appModuleHandler.NVDAProcessID`` is deprecated, use ``globalVars.appPid`` instead. (#13646)
- ``gui.quit`` is deprecated, use ``wx.CallAfter(mainFrame.onExitCommand, None)`` instead. (#13498)
-
% Insert new list items here as the alias appModule table should be kept at the bottom of this list
- Some alias appModules are marked as deprecated and will be removed in 2023.1.
- Some alias appModules are marked as deprecated.
Code which imports from one of them, should instead import from the replacement module. (#13366)
-

Expand Down

0 comments on commit 70f38a5

Please sign in to comment.