Skip to content

Commit

Permalink
Check unimacro feb24, go to version 4.1.5 (#50)
Browse files Browse the repository at this point in the history
* _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 <doug.ransom@gmail.com>
  • Loading branch information
quintijn and dougransom authored May 1, 2024
1 parent bc542ea commit 5c040a5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
33 changes: 18 additions & 15 deletions src/unimacro/UnimacroGrammars/_folders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -160,7 +163,6 @@ class ThisGrammar(ancestor):
<namepathcopy> = (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)
Expand All @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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']
Expand Down
2 changes: 1 addition & 1 deletion src/unimacro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

1 change: 1 addition & 0 deletions tests/test_grammar_folders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down

0 comments on commit 5c040a5

Please sign in to comment.