diff --git a/documentation/modules.rst b/documentation/modules.rst index 76ed240..2b7fcae 100644 --- a/documentation/modules.rst +++ b/documentation/modules.rst @@ -12,4 +12,5 @@ This section includes the available modules in the natlinkcore repository natlinkstatus natlinktimer readwritefile - + + diff --git a/pyproject.toml b/pyproject.toml index 9b3c28f..b2adf73 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,10 +9,10 @@ dynamic = ["version", "description"] requires-python = ">=3.9" readme = "readme.md" dependencies= [ - "natlink>=5.3.4", + "FreeSimpleGUI>=5.1.0", "pydebugstring >= 1.0.0.1", - "dtactions>=1.6.2", + "dtactions>=1.6.3", "platformdirs >= 4.2.0" ] classifiers=[ diff --git a/src/natlinkcore/__init__.py b/src/natlinkcore/__init__.py index 9172caf..53ca83c 100644 --- a/src/natlinkcore/__init__.py +++ b/src/natlinkcore/__init__.py @@ -1,6 +1,7 @@ '''Python portion of Natlink, a compatibility module for Dragon Naturally Speaking The python stuff including test modules''' -__version__="5.4.0" + +__version__="5.4.1" #pylint:disable= from pathlib import Path diff --git a/src/natlinkcore/config.py b/src/natlinkcore/config.py index d4c2cd1..062a91d 100644 --- a/src/natlinkcore/config.py +++ b/src/natlinkcore/config.py @@ -1,4 +1,4 @@ -#pylint:disable=C0114, C0115, C0116, R0913, E1101, R0911, R0914, W0702 +#pylint:disable=C0114, C0115, C0116, R0913, E1101, R0911, R0914, W0702, R0912, C0209 import sys import configparser import logging diff --git a/src/natlinkcore/natlinkstatus.py b/src/natlinkcore/natlinkstatus.py index 8cd2512..a805b03 100644 --- a/src/natlinkcore/natlinkstatus.py +++ b/src/natlinkcore/natlinkstatus.py @@ -326,9 +326,10 @@ def unimacroIsEnabled(self): uuDir = self.getUnimacroUserDirectory() if not uuDir: return False - # ugDir = uuDir # only _control self.getUnimacroGrammarsDirectory() + + # ugDir = self.getUnimacroGrammarsDirectory() # if not (ugDir and isdir(ugDir)): - # print(f'UnimacroGrammarsDirectory ({ugDir}) not present, please create') + # print(f'UnimacroGrammarsDirectory ({ugDir}) is not present, should be a subdirectory "unimacrogrammars" of {uDir}, please (re)run your pip install unimacro command, of rerun the "Configure Natlink with GUI" or "Configure Natlink with CLI"') # return False return True @@ -362,6 +363,9 @@ def getNatlinkIni(self): raise OSError(f'getNatlinkIni: not a valid file: "{path}"') return path + getnatlinkini = getNatlinkIni + + def getNatlink_Settingsdir(self): """get the directory where "natlink.ini" should be stored @@ -378,6 +382,8 @@ def getNatlink_Settingsdir(self): return str(natlink_settings_dir) + getnatlink_settingsdir = getNatlink_Settingsdir + def getUnimacroUserDirectory(self): isdir, abspath = os.path.isdir, os.path.abspath if self.UnimacroUserDirectory is not None: @@ -400,7 +406,7 @@ def getUnimacroUserDirectory(self): self.UnimacroUserDirectory = '' return '' - + getunimacrouserdirectory = getUnimacroUserDirectory def getUnimacroDirectory(self): """return the path to the UnimacroDirectory @@ -419,6 +425,9 @@ def getUnimacroDirectory(self): self.UnimacroDirectory = unimacro.__path__[-1] return self.UnimacroDirectory + getunimacrodirectory = getUnimacroDirectory + + def getUnimacroGrammarsDirectory(self): """return the path to the UnimacroGrammarDirectory @@ -442,6 +451,8 @@ def getUnimacroGrammarsDirectory(self): self.UnimacroGrammarsDirectory = um_grammars_dir return um_grammars_dir + getunimacrogrammarsdirectory = getUnimacroGrammarsDirectory + def getUnimacroDataDirectory(self): """return the path to the directory where grammars can store data. @@ -451,6 +462,8 @@ def getUnimacroDataDirectory(self): """ if self.UnimacroDataDirectory is not None: return self.UnimacroDataDirectory + if not self.unimacroIsEnabled(): + return '' natlink_settings_dir = self.getNatlink_Settingsdir() @@ -461,16 +474,22 @@ def getUnimacroDataDirectory(self): self.UnimacroDataDirectory = um_data_dir return um_data_dir + + getunimacrodatadirectory = getUnimacroDataDirectory def getNatlinkDirectory(self): """return the path of the NatlinkDirectory, where the _natlink_core.pyd package (C++ code) is """ return self.NatlinkDirectory + getnatlinkdirectory = getNatlinkDirectory + def getNatlinkcoreDirectory(self): """return the path of the natlinkcore package directory, same as thisDir! """ return self.NatlinkcoreDirectory + getnatlinkcoredirectory = getNatlinkcoreDirectory + def getUserDirectory(self): """return the path to the Natlink User directory @@ -500,7 +519,8 @@ def getUserDirectory(self): print('invalid path for UserDirectory: "{value}"') self.UserDirectory = '' return '' - + getuserdirectory = getUserDirectory + def getDragonflyDirectory(self): """return the path to the DragonflyDirectory @@ -519,7 +539,7 @@ def getDragonflyDirectory(self): self.DragonflyDirectory = str(Path(dragonfly2.__file__).parent) return self.DragonflyDirectory - + getdragonflydirectory = getDragonflyDirectory def getDragonflyUserDirectory(self): @@ -550,7 +570,7 @@ def getDragonflyUserDirectory(self): print('invalid path for DragonflyUserDirectory: "{value}"') self.DragonflyUserDirectory = '' return '' - + getdragonflyuserdirectory = getDragonflyUserDirectory def getVocolaUserDirectory(self): @@ -576,6 +596,8 @@ def getVocolaUserDirectory(self): print(f'invalid path for VocolaUserDirectory: "{value}" (expanded: "{expanded}")') self.VocolaUserDirectory = '' return '' + getvocolauserdirectory = getVocolaUserDirectory + def getVocolaDirectory(self): if self.VocolaDirectory is not None: @@ -588,7 +610,7 @@ def getVocolaDirectory(self): return '' self.VocolaDirectory = vocola2.__path__[-1] return self.VocolaDirectory - + getvocoladirectory = getVocolaDirectory def getVocolaGrammarsDirectory(self): """return the VocolaGrammarsDirectory, but only if Vocola is enabled @@ -611,6 +633,7 @@ def getVocolaGrammarsDirectory(self): voc_grammars_dir = natlinkcore.config.expand_path(value) self.VocolaGrammarsDirectory = voc_grammars_dir return voc_grammars_dir + getvocolagrammarsdirectory = getVocolaGrammarsDirectory def getDtactionsDirectory(self): """dtactions directory should be found with an import (like getUnimacroDirectory) @@ -625,10 +648,12 @@ def getDtactionsDirectory(self): return "" self.DtactionsDirectory = dtactions.__path__[-1] return self.DtactionsDirectory + getdtactionsdirectory = getDtactionsDirectory + def getAhkUserDir(self): return self.getAhkUserDirFromIni() - + getahkuserdir = getAhkUserDir def getAhkUserDirFromIni(self): isdir, abspath = os.path.isdir, os.path.abspath @@ -655,7 +680,7 @@ def getAhkExeDir(self): if not self.AhkExeDir is None: return self.AhkExeDir return self.getAhkExeDirFromIni() - + getahkexedir = getAhkExeDir def getAhkExeDirFromIni(self): isdir, abspath = os.path.isdir, os.path.abspath diff --git a/tests/buttonclicktest.py b/tests/buttonclicktest.py index ded28b0..bfb53ff 100644 --- a/tests/buttonclicktest.py +++ b/tests/buttonclicktest.py @@ -5,7 +5,7 @@ # the "ESP" error is hit. # When Dragon is running, it freezes, and must be closed with the windows task manager - +# with release 5.5.7 this should be OK, because PlayEvents has been disabled. import natlink from natlinkcore import natlinkutils diff --git a/tests/test_readwritefile.py b/tests/test_readwritefile.py index 211d370..f1f8624 100644 --- a/tests/test_readwritefile.py +++ b/tests/test_readwritefile.py @@ -108,57 +108,6 @@ def test_other_encodings_write_file(tmp_path): # _newFile = testDir/'cp1252.txt' # assert False, "QH TODO" - - -def test_nsapps_utf16(tmp_path): - """try the encodings from the nsapps ini file, version of Aaron - """ - testDir = tmp_path / testFolderName - testDir.mkdir() - # file_in = 'nsapps_aaron.ini' - file_in = 'nsapps_aaron.ini' - oldFile = mock_readwritefiledir/file_in - rwfile = ReadWriteFile(encodings=['utf-16le', 'utf-16be', 'utf-8']) # optional encoding - text = rwfile.readAnything(oldFile) - bom = rwfile.bom - encoding = rwfile.encoding - assert text[0] == ';' - - assert bom == [255, 254] - assert encoding == 'utf-16le' - - - newFile1 = 'output1' + file_in - newPath1 = testDir/newFile1 - rwfile.writeAnything(newPath1, text) - - assert filecmp.cmp(oldFile, newPath1) - - rwfile2 = ReadWriteFile(encodings=['utf-16le']) # optional encoding - text2 = rwfile2.readAnything(newPath1) - bom2 = rwfile2.bom - encoding2 = rwfile2.encoding - - tRaw = rwfile.rawText - tRaw2 = rwfile2.rawText - - assert text2[0] == ';' - assert bom2 == [255, 254] - assert encoding2 == 'utf-16le' - -# def test_latin1_cp1252_write_file(tmp_path): -# """ TODO (QH) to be done, these encodings do not take all characters, -# and need special attention. latin1 and cp1252 are hard to be distinguished -# For now, cp1252 (holding more (some special characters like the euro sign and quotes)) -# is favored over latin1. -# (as long as the "fallback" is utf-8, all write files should go well!) -# """ -# testDir = tmp_path / testFolderName -# testDir.mkdir() -# _newFile = testDir/ 'latin1.txt' -# _newFile = testDir/'cp1252.txt' -# assert False, "QH TODO" - def test_read_write_file(tmp_path): listdir, join, splitext = os.listdir, os.path.join, os.path.splitext