Skip to content

Commit 33232b2

Browse files
quintijndougransom
andauthored
several changes and bump to 5.4.1 (#87)
* several last changes, and bump to 5.4.1 --------- Co-authored-by: Doug Ransom <doug.ransom@gmail.com>
1 parent 7bad6a6 commit 33232b2

File tree

7 files changed

+42
-66
lines changed

7 files changed

+42
-66
lines changed

documentation/modules.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ This section includes the available modules in the natlinkcore repository
1212
natlinkstatus
1313
natlinktimer
1414
readwritefile
15-
15+
16+

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ dynamic = ["version", "description"]
99
requires-python = ">=3.9"
1010
readme = "readme.md"
1111
dependencies= [
12-
"natlink>=5.3.4",
12+
1313
"FreeSimpleGUI>=5.1.0",
1414
"pydebugstring >= 1.0.0.1",
15-
"dtactions>=1.6.2",
15+
"dtactions>=1.6.3",
1616
"platformdirs >= 4.2.0"
1717
]
1818
classifiers=[

src/natlinkcore/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'''Python portion of Natlink, a compatibility module for Dragon Naturally Speaking
22
The python stuff including test modules'''
3-
__version__="5.4.0"
3+
4+
__version__="5.4.1"
45
#pylint:disable=
56
from pathlib import Path
67

src/natlinkcore/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#pylint:disable=C0114, C0115, C0116, R0913, E1101, R0911, R0914, W0702
1+
#pylint:disable=C0114, C0115, C0116, R0913, E1101, R0911, R0914, W0702, R0912, C0209
22
import sys
33
import configparser
44
import logging

src/natlinkcore/natlinkstatus.py

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,10 @@ def unimacroIsEnabled(self):
326326
uuDir = self.getUnimacroUserDirectory()
327327
if not uuDir:
328328
return False
329-
# ugDir = uuDir # only _control self.getUnimacroGrammarsDirectory()
329+
330+
# ugDir = self.getUnimacroGrammarsDirectory()
330331
# if not (ugDir and isdir(ugDir)):
331-
# print(f'UnimacroGrammarsDirectory ({ugDir}) not present, please create')
332+
# 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"')
332333
# return False
333334
return True
334335

@@ -362,6 +363,9 @@ def getNatlinkIni(self):
362363
raise OSError(f'getNatlinkIni: not a valid file: "{path}"')
363364
return path
364365

366+
getnatlinkini = getNatlinkIni
367+
368+
365369
def getNatlink_Settingsdir(self):
366370
"""get the directory where "natlink.ini" should be stored
367371
@@ -378,6 +382,8 @@ def getNatlink_Settingsdir(self):
378382

379383
return str(natlink_settings_dir)
380384

385+
getnatlink_settingsdir = getNatlink_Settingsdir
386+
381387
def getUnimacroUserDirectory(self):
382388
isdir, abspath = os.path.isdir, os.path.abspath
383389
if self.UnimacroUserDirectory is not None:
@@ -400,7 +406,7 @@ def getUnimacroUserDirectory(self):
400406

401407
self.UnimacroUserDirectory = ''
402408
return ''
403-
409+
getunimacrouserdirectory = getUnimacroUserDirectory
404410

405411
def getUnimacroDirectory(self):
406412
"""return the path to the UnimacroDirectory
@@ -419,6 +425,9 @@ def getUnimacroDirectory(self):
419425
self.UnimacroDirectory = unimacro.__path__[-1]
420426
return self.UnimacroDirectory
421427

428+
getunimacrodirectory = getUnimacroDirectory
429+
430+
422431
def getUnimacroGrammarsDirectory(self):
423432
"""return the path to the UnimacroGrammarDirectory
424433
@@ -442,6 +451,8 @@ def getUnimacroGrammarsDirectory(self):
442451
self.UnimacroGrammarsDirectory = um_grammars_dir
443452
return um_grammars_dir
444453

454+
getunimacrogrammarsdirectory = getUnimacroGrammarsDirectory
455+
445456
def getUnimacroDataDirectory(self):
446457
"""return the path to the directory where grammars can store data.
447458
@@ -451,6 +462,8 @@ def getUnimacroDataDirectory(self):
451462
"""
452463
if self.UnimacroDataDirectory is not None:
453464
return self.UnimacroDataDirectory
465+
if not self.unimacroIsEnabled():
466+
return ''
454467

455468
natlink_settings_dir = self.getNatlink_Settingsdir()
456469

@@ -461,16 +474,22 @@ def getUnimacroDataDirectory(self):
461474
self.UnimacroDataDirectory = um_data_dir
462475

463476
return um_data_dir
477+
478+
getunimacrodatadirectory = getUnimacroDataDirectory
464479

465480
def getNatlinkDirectory(self):
466481
"""return the path of the NatlinkDirectory, where the _natlink_core.pyd package (C++ code) is
467482
"""
468483
return self.NatlinkDirectory
469484

485+
getnatlinkdirectory = getNatlinkDirectory
486+
470487
def getNatlinkcoreDirectory(self):
471488
"""return the path of the natlinkcore package directory, same as thisDir!
472489
"""
473490
return self.NatlinkcoreDirectory
491+
getnatlinkcoredirectory = getNatlinkcoreDirectory
492+
474493

475494
def getUserDirectory(self):
476495
"""return the path to the Natlink User directory
@@ -500,7 +519,8 @@ def getUserDirectory(self):
500519
print('invalid path for UserDirectory: "{value}"')
501520
self.UserDirectory = ''
502521
return ''
503-
522+
getuserdirectory = getUserDirectory
523+
504524
def getDragonflyDirectory(self):
505525
"""return the path to the DragonflyDirectory
506526
@@ -519,7 +539,7 @@ def getDragonflyDirectory(self):
519539

520540
self.DragonflyDirectory = str(Path(dragonfly2.__file__).parent)
521541
return self.DragonflyDirectory
522-
542+
getdragonflydirectory = getDragonflyDirectory
523543

524544

525545
def getDragonflyUserDirectory(self):
@@ -550,7 +570,7 @@ def getDragonflyUserDirectory(self):
550570
print('invalid path for DragonflyUserDirectory: "{value}"')
551571
self.DragonflyUserDirectory = ''
552572
return ''
553-
573+
getdragonflyuserdirectory = getDragonflyUserDirectory
554574

555575
def getVocolaUserDirectory(self):
556576

@@ -576,6 +596,8 @@ def getVocolaUserDirectory(self):
576596
print(f'invalid path for VocolaUserDirectory: "{value}" (expanded: "{expanded}")')
577597
self.VocolaUserDirectory = ''
578598
return ''
599+
getvocolauserdirectory = getVocolaUserDirectory
600+
579601

580602
def getVocolaDirectory(self):
581603
if self.VocolaDirectory is not None:
@@ -588,7 +610,7 @@ def getVocolaDirectory(self):
588610
return ''
589611
self.VocolaDirectory = vocola2.__path__[-1]
590612
return self.VocolaDirectory
591-
613+
getvocoladirectory = getVocolaDirectory
592614

593615
def getVocolaGrammarsDirectory(self):
594616
"""return the VocolaGrammarsDirectory, but only if Vocola is enabled
@@ -611,6 +633,7 @@ def getVocolaGrammarsDirectory(self):
611633
voc_grammars_dir = natlinkcore.config.expand_path(value)
612634
self.VocolaGrammarsDirectory = voc_grammars_dir
613635
return voc_grammars_dir
636+
getvocolagrammarsdirectory = getVocolaGrammarsDirectory
614637

615638
def getDtactionsDirectory(self):
616639
"""dtactions directory should be found with an import (like getUnimacroDirectory)
@@ -625,10 +648,12 @@ def getDtactionsDirectory(self):
625648
return ""
626649
self.DtactionsDirectory = dtactions.__path__[-1]
627650
return self.DtactionsDirectory
651+
getdtactionsdirectory = getDtactionsDirectory
652+
628653

629654
def getAhkUserDir(self):
630655
return self.getAhkUserDirFromIni()
631-
656+
getahkuserdir = getAhkUserDir
632657

633658
def getAhkUserDirFromIni(self):
634659
isdir, abspath = os.path.isdir, os.path.abspath
@@ -655,7 +680,7 @@ def getAhkExeDir(self):
655680
if not self.AhkExeDir is None:
656681
return self.AhkExeDir
657682
return self.getAhkExeDirFromIni()
658-
683+
getahkexedir = getAhkExeDir
659684

660685
def getAhkExeDirFromIni(self):
661686
isdir, abspath = os.path.isdir, os.path.abspath

tests/buttonclicktest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# the "ESP" error is hit.
66

77
# When Dragon is running, it freezes, and must be closed with the windows task manager
8-
8+
# with release 5.5.7 this should be OK, because PlayEvents has been disabled.
99

1010
import natlink
1111
from natlinkcore import natlinkutils

tests/test_readwritefile.py

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -108,57 +108,6 @@ def test_other_encodings_write_file(tmp_path):
108108
# _newFile = testDir/'cp1252.txt'
109109
# assert False, "QH TODO"
110110

111-
112-
113-
def test_nsapps_utf16(tmp_path):
114-
"""try the encodings from the nsapps ini file, version of Aaron
115-
"""
116-
testDir = tmp_path / testFolderName
117-
testDir.mkdir()
118-
# file_in = 'nsapps_aaron.ini'
119-
file_in = 'nsapps_aaron.ini'
120-
oldFile = mock_readwritefiledir/file_in
121-
rwfile = ReadWriteFile(encodings=['utf-16le', 'utf-16be', 'utf-8']) # optional encoding
122-
text = rwfile.readAnything(oldFile)
123-
bom = rwfile.bom
124-
encoding = rwfile.encoding
125-
assert text[0] == ';'
126-
127-
assert bom == [255, 254]
128-
assert encoding == 'utf-16le'
129-
130-
131-
newFile1 = 'output1' + file_in
132-
newPath1 = testDir/newFile1
133-
rwfile.writeAnything(newPath1, text)
134-
135-
assert filecmp.cmp(oldFile, newPath1)
136-
137-
rwfile2 = ReadWriteFile(encodings=['utf-16le']) # optional encoding
138-
text2 = rwfile2.readAnything(newPath1)
139-
bom2 = rwfile2.bom
140-
encoding2 = rwfile2.encoding
141-
142-
tRaw = rwfile.rawText
143-
tRaw2 = rwfile2.rawText
144-
145-
assert text2[0] == ';'
146-
assert bom2 == [255, 254]
147-
assert encoding2 == 'utf-16le'
148-
149-
# def test_latin1_cp1252_write_file(tmp_path):
150-
# """ TODO (QH) to be done, these encodings do not take all characters,
151-
# and need special attention. latin1 and cp1252 are hard to be distinguished
152-
# For now, cp1252 (holding more (some special characters like the euro sign and quotes))
153-
# is favored over latin1.
154-
# (as long as the "fallback" is utf-8, all write files should go well!)
155-
# """
156-
# testDir = tmp_path / testFolderName
157-
# testDir.mkdir()
158-
# _newFile = testDir/ 'latin1.txt'
159-
# _newFile = testDir/'cp1252.txt'
160-
# assert False, "QH TODO"
161-
162111

163112
def test_read_write_file(tmp_path):
164113
listdir, join, splitext = os.listdir, os.path.join, os.path.splitext

0 commit comments

Comments
 (0)