Skip to content

Commit 42151e4

Browse files
Merge 1da2d23 into 66bcf8e
2 parents 66bcf8e + 1da2d23 commit 42151e4

20 files changed

Lines changed: 110 additions & 47 deletions

File tree

source/COMRegistrationFixes/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import os
99
import subprocess
1010
import winVersion
11+
import globalVars
1112
from logHandler import log
1213

1314
# Particular 64 bit / 32 bit system paths
@@ -53,7 +54,7 @@ def applyRegistryPatch(fileName,wow64=False):
5354
log.debug("Applied registry patch: %s with %s"%(fileName,regedit))
5455

5556

56-
OLEACC_REG_FILE_PATH = os.path.abspath(os.path.join("COMRegistrationFixes", "oleaccProxy.reg"))
57+
OLEACC_REG_FILE_PATH = os.path.join(globalVars.appDir, "COMRegistrationFixes", "oleaccProxy.reg")
5758
def fixCOMRegistrations():
5859
"""
5960
Registers most common COM proxies, in case they had accidentally been unregistered or overwritten by 3rd party software installs/uninstalls.

source/NVDAHelper.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929
import time
3030
import globalVars
3131

32-
versionedLibPath='lib'
32+
versionedLibPath = os.path.join(globalVars.appDir, 'lib')
3333
if os.environ.get('PROCESSOR_ARCHITEW6432') == 'ARM64':
34-
versionedLib64Path = 'libArm64'
34+
versionedLib64Path = os.path.join(globalVars.appDir, 'libArm64')
3535
else:
36-
versionedLib64Path = 'lib64'
36+
versionedLib64Path = os.path.join(globalVars.appDir, 'lib64')
3737
if getattr(sys,'frozen',None):
3838
# Not running from source. Libraries are in a version-specific directory
3939
versionedLibPath=os.path.join(versionedLibPath,versionInfo.version)

source/NVDAObjects/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"""Module that contains the base NVDA object type with dynamic class creation support,
99
as well as the associated TextInfo class."""
1010

11+
import os
1112
import time
1213
import re
1314
import weakref
@@ -31,6 +32,8 @@
3132
import brailleInput
3233
import locationHelper
3334
import aria
35+
import globalVars
36+
3437

3538
class NVDAObjectTextInfo(textInfos.offsets.OffsetsTextInfo):
3639
"""A default TextInfo which is used to enable text review of information about widgets that don't support text content.
@@ -1030,7 +1033,7 @@ def _reportErrorInPreviousWord(self):
10301033
# No error.
10311034
return
10321035
import nvwave
1033-
nvwave.playWaveFile(r"waves\textError.wav")
1036+
nvwave.playWaveFile(os.path.join(globalVars.appDir, "waves", "textError.wav"))
10341037

10351038
def event_liveRegionChange(self):
10361039
"""

source/NVDAObjects/behaviors.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import ui
3030
import braille
3131
import nvwave
32+
import globalVars
33+
3234

3335
class ProgressBar(NVDAObject):
3436

@@ -796,15 +798,15 @@ def event_suggestionsOpened(self):
796798
# Translators: Announced in braille when suggestions appear when search term is entered in various search fields such as Start search box in Windows 10.
797799
braille.handler.message(_("Suggestions"))
798800
if config.conf["presentation"]["reportAutoSuggestionsWithSound"]:
799-
nvwave.playWaveFile(r"waves\suggestionsOpened.wav")
801+
nvwave.playWaveFile(os.path.join(globalVars.appDir, "waves", "suggestionsOpened.wav"))
800802

801803
def event_suggestionsClosed(self):
802804
"""Called when suggestions list or container is closed.
803805
Subclasses should provide custom implementations if possible.
804806
By default NVDA will announce this via speech, braille or via a sound.
805807
"""
806808
if config.conf["presentation"]["reportAutoSuggestionsWithSound"]:
807-
nvwave.playWaveFile(r"waves\suggestionsClosed.wav")
809+
nvwave.playWaveFile(os.path.join(globalVars.appDir, "waves", "suggestionsClosed.wav"))
808810

809811
class WebDialog(NVDAObject):
810812
"""

source/brailleTables.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@
66
"""Manages information about available braille translation tables.
77
"""
88

9+
import os
910
import collections
1011
from locale import strxfrm
12+
import globalVars
13+
1114

1215
#: The directory in which liblouis braille tables are located.
13-
TABLES_DIR = r"louis\tables"
16+
TABLES_DIR = os.path.join(globalVars.appDir, "louis", "tables")
1417

1518
#: Information about a braille table.
1619
#: This has the following attributes:

source/characterProcessing.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def __init__(self,locale):
7878
@type locale: string
7979
"""
8080
self._entries = {}
81-
fileName=os.path.join('locale',locale,'characterDescriptions.dic')
81+
fileName = os.path.join(globalVars.appDir, 'locale', locale, 'characterDescriptions.dic')
8282
if not os.path.isfile(fileName):
8383
raise LookupError(fileName)
8484
f = codecs.open(fileName,"r","utf_8_sig",errors="replace")
@@ -367,12 +367,14 @@ def _getSpeechSymbolsForLocale(locale):
367367
# Load the data before loading other symbols,
368368
# in order to allow translators to override them.
369369
try:
370-
builtin.load(os.path.join("locale", locale, "cldr.dic"),
371-
allowComplexSymbols=False)
370+
builtin.load(
371+
os.path.join(globalVars.appDir, "locale", locale, "cldr.dic"),
372+
allowComplexSymbols=False
373+
)
372374
except IOError:
373375
log.debugWarning("No CLDR data for locale %s" % locale)
374376
try:
375-
builtin.load(os.path.join("locale", locale, "symbols.dic"))
377+
builtin.load(os.path.join(globalVars.appDir, "locale", locale, "symbols.dic"))
376378
except IOError:
377379
_noSymbolLocalesCache.add(locale)
378380
raise LookupError("No symbol information for locale %s" % locale)

source/config/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def isInstalledCopy():
8383
return False
8484
winreg.CloseKey(k)
8585
try:
86-
return os.stat(instDir)==os.stat(os.getcwd())
86+
return os.stat(instDir) == os.stat(globalVars.appDir)
8787
except WindowsError:
8888
return False
8989

@@ -125,7 +125,7 @@ def getUserDefaultConfigPath(useInstalledPathIfExists=False):
125125
# Therefore add a suffix to the directory to make it specific to Windows Store application versions.
126126
installedUserConfigPath+='_appx'
127127
return installedUserConfigPath
128-
return u'.\\userConfig\\'
128+
return os.path.join(globalVars.appDir, 'userConfig')
129129

130130
def getSystemConfigPath():
131131
if isInstalledCopy():

source/core.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def main():
232232
log.info("Developer Scratchpad mode enabled")
233233
if not globalVars.appArgs.minimal and config.conf["general"]["playStartAndExitSounds"]:
234234
try:
235-
nvwave.playWaveFile("waves\\start.wav")
235+
nvwave.playWaveFile(os.path.join(globalVars.appDir, "waves", "start.wav"))
236236
except:
237237
pass
238238
logHandler.setLogLevelFromConfig()
@@ -298,7 +298,10 @@ def onEndSession(evt):
298298
speech.cancelSpeech()
299299
if not globalVars.appArgs.minimal and config.conf["general"]["playStartAndExitSounds"]:
300300
try:
301-
nvwave.playWaveFile("waves\\exit.wav",asynchronous=False)
301+
nvwave.playWaveFile(
302+
os.path.join(globalVars.appDir, "waves", "exit.wav"),
303+
asynchronous=False
304+
)
302305
except:
303306
pass
304307
log.info("Windows session ending")
@@ -410,7 +413,7 @@ def handlePowerStatusChange(self):
410413
if not wxLang and '_' in lang:
411414
wxLang=locale.FindLanguageInfo(lang.split('_')[0])
412415
if hasattr(sys,'frozen'):
413-
locale.AddCatalogLookupPathPrefix(os.path.join(os.getcwd(),"locale"))
416+
locale.AddCatalogLookupPathPrefix(os.path.join(globalVars.appDir, "locale"))
414417
# #8064: Wx might know the language, but may not actually contain a translation database for that language.
415418
# If we try to initialize this language, wx will show a warning dialog.
416419
# #9089: some languages (such as Aragonese) do not have language info, causing language getter to fail.
@@ -591,7 +594,10 @@ def run(self):
591594

592595
if not globalVars.appArgs.minimal and config.conf["general"]["playStartAndExitSounds"]:
593596
try:
594-
nvwave.playWaveFile("waves\\exit.wav",asynchronous=False)
597+
nvwave.playWaveFile(
598+
os.path.join(globalVars.appDir, "waves", "exit.wav"),
599+
asynchronous=False
600+
)
595601
except:
596602
pass
597603
# #5189: Destroy the message window as late as possible

source/fonts/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# brailleViewer.py
21
# A part of NonVisual Desktop Access (NVDA)
32
# Copyright (C) 2019 NV Access Limited
43
# This file is covered by the GNU General Public License.
54
# See the file COPYING for more details.
65
from typing import List
76

7+
import globalVars
88
from logHandler import log
99
import os
1010
from ctypes import WinDLL
@@ -13,7 +13,7 @@
1313
Loads custom fonts for use in NVDA.
1414
"""
1515

16-
fontsDir = os.path.abspath("fonts")
16+
fontsDir = os.path.join(globalVars.appDir, "fonts")
1717

1818

1919
def _isSupportedFontPath(f: str) -> bool:

source/gui/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
updateCheck = None
4545

4646
### Constants
47-
NVDA_PATH = os.getcwd()
47+
NVDA_PATH = globalVars.appDir
4848
ICON_PATH=os.path.join(NVDA_PATH, "images", "nvda.ico")
4949
DONATE_URL = "http://www.nvaccess.org/donate/"
5050

@@ -57,7 +57,7 @@ def getDocFilePath(fileName, localized=True):
5757
if hasattr(sys, "frozen"):
5858
getDocFilePath.rootPath = os.path.join(NVDA_PATH, "documentation")
5959
else:
60-
getDocFilePath.rootPath = os.path.abspath(os.path.join("..", "user_docs"))
60+
getDocFilePath.rootPath = os.path.join(NVDA_PATH, "..", "user_docs")
6161

6262
if localized:
6363
lang = languageHandler.getLanguage()

0 commit comments

Comments
 (0)