Skip to content

Commit

Permalink
several changes and bump to 5.4.1 (#87)
Browse files Browse the repository at this point in the history
* several last changes, and bump to 5.4.1
---------

Co-authored-by: Doug Ransom <doug.ransom@gmail.com>
  • Loading branch information
quintijn and dougransom authored Aug 22, 2024
1 parent 7bad6a6 commit 33232b2
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 66 deletions.
3 changes: 2 additions & 1 deletion documentation/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ This section includes the available modules in the natlinkcore repository
natlinkstatus
natlinktimer
readwritefile



4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand Down
3 changes: 2 additions & 1 deletion src/natlinkcore/__init__.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/natlinkcore/config.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
43 changes: 34 additions & 9 deletions src/natlinkcore/natlinkstatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -400,7 +406,7 @@ def getUnimacroUserDirectory(self):

self.UnimacroUserDirectory = ''
return ''

getunimacrouserdirectory = getUnimacroUserDirectory

def getUnimacroDirectory(self):
"""return the path to the UnimacroDirectory
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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()

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -519,7 +539,7 @@ def getDragonflyDirectory(self):

self.DragonflyDirectory = str(Path(dragonfly2.__file__).parent)
return self.DragonflyDirectory

getdragonflydirectory = getDragonflyDirectory


def getDragonflyUserDirectory(self):
Expand Down Expand Up @@ -550,7 +570,7 @@ def getDragonflyUserDirectory(self):
print('invalid path for DragonflyUserDirectory: "{value}"')
self.DragonflyUserDirectory = ''
return ''

getdragonflyuserdirectory = getDragonflyUserDirectory

def getVocolaUserDirectory(self):

Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/buttonclicktest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 0 additions & 51 deletions tests/test_readwritefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 33232b2

Please sign in to comment.