dictation-toolbox / unimacro

Other
3 stars 1 forks source link

Loading of Unimacro Scripts #28

Open dougransom opened 2 years ago

dougransom commented 2 years ago

It strikes me as odd that Unimacro Scripts like _folders.py etc. are stored in the users unimacro/ActiveGrammars. I could see this maybe (but not likely) if a user were developing a script.

Also, how are scripts currently upgraded if new ones show up from a unimacro or other package upgrade?

Now that Unimacro is python package, the configuration file could (if we make changes) just list the unimacro scripts that are enabled. Then the unimacro script loader loads them with the equivalent of an import statement. In most cases, it will load them out of an installed python package. If i have my own script _doug.py i make sure it is installed as a python package or in the python path somewhere.

For example, in the config file

[enabled] 
 unimacro/_brackets
 unimacro/_folders
dougscripts/_doug

[disabled]
just some scripts we might want to renabled some day...

The unimacro loader just performs

import unimacro/_brackets
import unimacro/_folders
import dougscripts/_doug

the next time I do a pip upgrade, my unimacro scripts are probably all updated to the latest.

quintijn commented 2 years ago

I have a python script check_unimacro_grammars.py which should do just this. Only smoke tested, but I think it basically works. https://github.com/dictation-toolbox/unimacro/blob/master/src/unimacro/check_unimacro_grammars.py

Will work on the documentation of this.