From 5c040a5e668c9cbf62c6b6fe0307fbe2197e8da6 Mon Sep 17 00:00:00 2001 From: Quintijn Hoogenboom Date: Wed, 1 May 2024 17:58:43 +0200 Subject: [PATCH] Check unimacro feb24, go to version 4.1.5 (#50) * _general.py fixed several dgndictation things (also in nsformat.py of natlinkcore) * fixed a few flaws in _brackets, started test_grammar_brackets.py * brought win32clipboard under try finally * tidy up _general * few small things _clickbyvoice.py, mostly tyding up things * work in progress _folders, getting natlinktimer again at work... * logging _folders settings * working on the _folders grammar option and checking automatic tracking of recent folders and files en subfolders * refinement with switching on a unimacro grammar * effort to diminish the errors when an ini file is invalid... * _folders automatic catching files and folders made working again, including the natlinktimer. * add number simple.ini to sample ini files... * changed extenvvars in dtactions, with changes here too (when error persists, try "pip upate dtactions" * go to version 4.1.5 --------- Co-authored-by: Doug Ransom --- src/unimacro/UnimacroGrammars/_folders.py | 33 ++++++++++++----------- src/unimacro/__init__.py | 2 +- tests/test_grammar_folders.py | 1 + 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/unimacro/UnimacroGrammars/_folders.py b/src/unimacro/UnimacroGrammars/_folders.py index b541e13..7b16604 100644 --- a/src/unimacro/UnimacroGrammars/_folders.py +++ b/src/unimacro/UnimacroGrammars/_folders.py @@ -76,6 +76,9 @@ # from unimacro.unimacro_wxpythondialogs import InputBox # import natlinkcore.natlinkutils as natut +# manipulating file names with env variables etc... +envvars = extenvvars.ExtEnvVars() + thisDir = str(Path(__file__).parent) status = natlinkstatus.NatlinkStatus() # for getting unicode explorer window titles: @@ -160,7 +163,6 @@ class ThisGrammar(ancestor): = (copy (name|path)) | ((name|path) copy); """ - def initialize(self): # self.envDict = natlinkcorefunctions.getAllFolderEnvironmentVariables() # for (generalised) environment variables self.subfiles = self.subfiles = self.activeFolder = self.activeTimerFolder = None # for catching on the fly in explorer windows (CabinetClassW) @@ -169,11 +171,12 @@ def initialize(self): self.dialogNumberRange = [] # ditto self.catchRemember = "" self.inTimerRecentFolders = False - self.prevDisplayRecentFolders = None # displaying recent folders list self.prevActiveFolder = None self.subfoldersDict = {} self.subfilesDict = {} self.foldersSet = set() + + if not self.language: self.error("no valid language in grammar "+__name__+" grammar not initialized") return @@ -547,7 +550,7 @@ def getFolderFromVirtualDrive(self, vd): also make alternative paths possible like (C|D):/Documents """ # natlinkcorefunctions.printAllEnvVariables() - vd = extenvvars.expandEnvVariables(vd) + vd = envvars.expandEnvVariables(vd) for possiblePath in loop_through_alternative_paths(vd): folder = self.substituteFolder(possiblePath) if os.path.isdir(folder): @@ -624,8 +627,8 @@ def getActiveFolder(self, hndle=None, className=None): self.debug("getActiveFolder, got: %s",nf) self.prevActiveFolder = nf return nf - result = extenvvars.getFolderFromLibraryName(f) - if result and os.path.isdir(f): + result = envvars.getFolderFromLibraryName(f) + if result and os.path.isdir(result): self.debug("getActiveFolder, via getFolderFromLibraryName %s: %s", f, result) return os.path.normpath(result) self.warning('getActiveFolder, strange invalid path for folder: %s', f) @@ -874,18 +877,13 @@ def displayRecentFolders(self): mess_list = ["--- recent folders:"] if not self.recentfoldersDict: message = 'recent folders list is empty at the moment' - self.prevDisplayRecentFolders = message self.info(message) return for name, value in reversed(self.recentfoldersDict.items()): mess_list.append('- %s: %s'% (name, value)) mess_list.append('-'*20) message = '\n'.join(mess_list) - if message == self.prevDisplayRecentFolders: - self.info("recent folders, no change") - else: - self.prevDisplayRecentFolders = message - Message(message) + Message(message) # def gotoRecentFolder(self, chooseNum): @@ -1260,9 +1258,9 @@ def gotResults_remember(self, words, fullResults): # reset variables, no action in gotResults: self.wantedFile = self.wantedFolder = self.wantedWebsite = "" self.info(f'thisDir: {thisDir}') - UnimacroDirectory = extenvvars.expandEnvVariableAtStart('%Unimacro%') + UnimacroDirectory = envvars.expandEnvVariableAtStart('%Unimacro%') self.info(f'UnimacroDirectory: {UnimacroDirectory}') - UnimacroGrammarsDirectory = extenvvars.expandEnvVariableAtStart('%UnimacroGrammars%') + UnimacroGrammarsDirectory = envvars.expandEnvVariableAtStart('%UnimacroGrammars%') self.info(f'UnimacroGrammarsDirectory: {UnimacroGrammarsDirectory}') makeFromTemplateAndExecute(UnimacroDirectory, "unimacrofoldersremembertemplate.py", UnimacroGrammarsDirectory, "rememberdialog.py", prompt, text, default, inifile, section, value, pausetime=pausetime) @@ -1629,7 +1627,7 @@ def substituteEnvVariable(self,folder): With expandEnvVars, also NATLINK and related variables can be handled. NATLINKDIRECTORY, COREDIRECTORY etc. """ - substitute = extenvvars.expandEnvVariables(folder) + substitute = envvars.expandEnvVariables(folder) return substitute def substituteFilename(self, filename): @@ -2447,10 +2445,15 @@ def unload(): thisGrammar = ThisGrammar(inifile_stem="_folders") # thisGrammar.startInifile() thisGrammar.initialize() + # print(thisGrammar.envvars) + # get hndle of a explore window (via _general "give window info") and try interactive + # thisGrammar.catchTimerRecentFolders(132524, "CabinetWClass") + active_folder = thisGrammar.getActiveFolder(198434) + print(f'active_folder: {active_folder}') # get hndle of a explore window (via _general "give window info") and try interactive # thisGrammar.catchTimerRecentFolders(132524, "CabinetWClass") - thisGrammar.getActiveFolder(67062) + thisGrammar.getActiveFol>>> master thisGrammar.displayRecentFolders() # # Words = ['folder', 'dtactions'] diff --git a/src/unimacro/__init__.py b/src/unimacro/__init__.py index 9da60fb..f3f0847 100644 --- a/src/unimacro/__init__.py +++ b/src/unimacro/__init__.py @@ -21,5 +21,5 @@ def control_logger_name() -> str : def logname() -> str: """ Returns the name of the unimacro logger.""" return "natlink.unimacro" -__version__ = '4.1.4.5' +__version__ = '4.1.5' diff --git a/tests/test_grammar_folders.py b/tests/test_grammar_folders.py index 8e46b02..de4144d 100644 --- a/tests/test_grammar_folders.py +++ b/tests/test_grammar_folders.py @@ -5,6 +5,7 @@ thisDir = Path(__file__).parent + def test_fill_folders_list(unimacro_setup): """see if (with debugging) the list folders (foldersDict) is filled """