Skip to content

Commit ce285b0

Browse files
committed
Change lookup for MathCAT rules to use the file location, not hard coding in the path.
Fixes #79 (hopefully)
1 parent 5d4b179 commit ce285b0

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

addon/globalPlugins/MathCAT/MathCATPreferences.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(self, parent):
4848

4949
# load the logo into the dialog
5050
full_path_to_logo = (
51-
os.path.expanduser("~") + "\\AppData\\Roaming\\nvda\\addons\\mathCAT\\globalPlugins\\MathCAT\\logo.png"
51+
os.path.join(os.path.dirname(os.path.abspath(__file__)), "logo.png")
5252
)
5353
if os.path.exists(full_path_to_logo):
5454
self.m_bitmapLogo.SetBitmap(wx.Bitmap(full_path_to_logo))
@@ -82,12 +82,12 @@ def __init__(self, parent):
8282
@staticmethod
8383
def path_to_languages_folder():
8484
# the user preferences file is stored at: MathCAT\Rules\Languages
85-
return os.path.expanduser("~") + "\\AppData\\Roaming\\nvda\\addons\\mathCAT\\globalPlugins\\MathCAT\\Rules\\Languages"
85+
return os.path.join(os.path.dirname(os.path.abspath(__file__)), "Rules", "Languages")
8686

8787
@staticmethod
8888
def path_to_braille_folder():
8989
# the user preferences file is stored at: MathCAT\Rules\Languages
90-
return os.path.expanduser("~") + "\\AppData\\Roaming\\nvda\\addons\\mathCAT\\globalPlugins\\MathCAT\\Rules\\Braille"
90+
return os.path.join(os.path.dirname(os.path.abspath(__file__)), "Rules", "Braille")
9191

9292
@staticmethod
9393
def LanguagesDict() -> Dict[str, str]:
@@ -373,10 +373,8 @@ def getSpeechStyleFromDirectory(dir: str, lang: str) -> list[str]:
373373
languageCode = getCurrentLanguage().lower().replace("_", "-")
374374
languageCode = languageCode.replace("-", "\\")
375375

376-
languagePath = (
377-
os.path.expanduser("~")
378-
+ "\\AppData\\Roaming\\nvda\\addons\\MathCAT\\globalPlugins\\MathCAT\\Rules\\Languages\\"
379-
)
376+
languagePath = UserInterface.path_to_languages_folder() + "\\"
377+
log.info(f"languagePath={languagePath}")
380378
# populate the m_choiceSpeechStyle choices
381379
all_style_files = [
382380
# remove "_Rules.yaml" from the list
@@ -529,10 +527,8 @@ def get_ui_values(self):
529527

530528
@staticmethod
531529
def path_to_default_preferences():
532-
# the default preferences file is:
533-
# C:\Users\<user-name>AppData\Roaming\\nvda\\addons\\MathCAT\\globalPlugins\\MathCAT\\Rules\\prefs.yaml
534530
return (
535-
os.path.expanduser("~") + "\\AppData\\Roaming\\nvda\\addons\\MathCAT\\globalPlugins\\MathCAT\\Rules\\prefs.yaml"
531+
os.path.join(os.path.dirname(os.path.abspath(__file__)), "Rules", "prefs.yaml")
536532
)
537533

538534
@staticmethod

0 commit comments

Comments
 (0)