Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

several changes and bump to 5.4.1 #87

Merged
merged 29 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b6f8c14
minor adjustment natlinkstatus.py
quintijn Apr 28, 2024
d2bbd17
working on convert NATLINK_USERDIR to NATLINK_SETTINGSDIR (environmen…
quintijn Apr 28, 2024
2b09ef9
loader.py anticipating on change from NATLINK_USERDIR to NATLINK_SETT…
quintijn May 1, 2024
51e1613
changing in loader check for and in natlinkconfigfunctions change fro…
quintijn May 1, 2024
1c86f1a
some tidying up things
quintijn May 1, 2024
b88dcae
bump to (release) 5.3.11
quintijn May 1, 2024
a30486e
Merge branch 'dictation-toolbox:main' into dr16efforts
quintijn May 1, 2024
0e2ecff
remove natlink from the dependencies of natlinkcore... update dtactio…
quintijn May 2, 2024
343a8f3
Merge branch 'dr16efforts' of github.com:dougransom/natlinkcore into …
quintijn May 2, 2024
118df97
checking edge cases of configuration files
quintijn Jun 10, 2024
381639f
improved some details, but foremost includeUnimacroVchLineInVocolaFil…
quintijn Jun 10, 2024
66afc9f
added entry point for loggers
dougransom Feb 29, 2024
adb8c36
added build in the dev tools.
dougransom Mar 2, 2024
47c0a3e
checking edge cases of configuration files
quintijn Jun 10, 2024
ac8da42
improved some details, but foremost includeUnimacroVchLineInVocolaFil…
quintijn Jun 10, 2024
ae037e7
with Aaron, changed natlinkcore.toml
quintijn Jun 10, 2024
36526f9
Merge branch 'improveconfig' of github.com:dougransom/natlinkcore int…
quintijn Jun 10, 2024
bf0d321
changes because of the NATLINK_SETTINGSDIR setting (change from NATLI…
quintijn Jun 26, 2024
65a93a1
add an assert statement in def openConfigFile of natlinkconfigfunctio…
quintijn Jun 27, 2024
2b545d1
fixed a few tests and tidied up config things and user messages
quintijn Jul 22, 2024
eea6641
fixed the getting of repository names as directory (especially when e…
quintijn Jul 22, 2024
4855fee
played a bit with testing, renamed mock_userdir to mock_settingsdir
quintijn Aug 7, 2024
e347a42
working on sample macros, added _sample_move_natlinktimer.py for cont…
quintijn Aug 10, 2024
6b7776b
changes to loader.py, message when NATLINK_SETTINGSDIR is defined.
quintijn Aug 10, 2024
3702eee
changing dependencies for dtactions 1.6.2
quintijn Aug 10, 2024
061932a
going to pip release 5.4.0
quintijn Aug 10, 2024
1ce5a68
several last changes, and bump to 5.4.1
quintijn Aug 22, 2024
0e68c77
updated dependency: dtactions 1.6.3
quintijn Aug 22, 2024
0ec5699
Merge branch 'main' into improveconfig
quintijn Aug 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading