loader
The loader is what was natlinkmain in python(2) NatLink: it loads the various
modules according to the config file natlink.ini.
Moreover, it also handles callbacks from Dragon/Natlink.
- class NatlinkMain(*args, **kwargs)[source]
main class of Natlink, make it a “singleton”
- get_load_on_begin_utterance() Any[source]
this value is most often True or False, taken from the config file
It can also be (set to) a positive int, with which it does the load_on_begin_utterance so many times. After these utterances, the value falls back to False.
With Vocola, this value is set to 1, for a one time load_on_begin_utterance, wihtout the need to toggle the microphone.
- get_user_language(DNSuserDirectory)[source]
return the user language (default “enx”) from Dragon inifiles
like “nld” for Dutch, etc.
- getconfigsetting(section: str, option: Any | None = None, filepath: Any | None = None, func: Any | None = None) str[source]
get a setting from possibly an inifile other than natlink.ini
Take a string as input, which is obtained from readwritefile.py, handling different encodings and possible BOM marks.
When no “option” is passed, the contents of the section are returned (a list of options)
func can be configparser.getint or configparser.getboolean if needed, otherwise configparser.get (str) is taken. pass: func=’getboolean’ or func=’getint’.
- property language: str
holds the language of the current profile (default ‘enx’)
- property load_on_begin_utterance: Any
this value is most often True or False, taken from the config file
It can also be (set to) a positive int, with which it does the load_on_begin_utterance so many times. After these utterances, the value falls back to False.
With Vocola, this value is set to 1, for a one time load_on_begin_utterance, wihtout the need to toggle the microphone.
- on_change_callback(change_type: str, args: Any) None[source]
on_change_callback, when another user profile is chosen, or when the mic state changes
- property profile: str
holds the directory profile of current user profile
- set_load_on_begin_utterance(value: Any)[source]
set the value for loading at each utterance to True, False or positive int
For Vocola, setting this value to 1 did not work, setting to 2 does, so you need one extra utterance for a new vocola command to come through.
- set_user_language(args: Any | None = None)[source]
can be called from other module to explicitly set the user language to ‘enx’, ‘nld’, etc
- unload_all_loaded_modules()[source]
unload the modules that are loaded, and empty the bad modules list
- property user: str
holds the name of the current user profile
- config_locations() Iterable[str][source]
give two possible locations, the wanted and the “fallback” location
wanted: in the ‘.natlink’ subdirectory of home or in “NATLINK_USERDIR”, this variable is going to be replaced by “NATLINK_SETTINGSDIR”. name is always ‘natlink.ini’
the fallback location is in the installed files, and provides the frame for the config file. with the configurenatlink (natlinkconfigfunction.py or configfurenatlink.pyw) the fallback version of the config file is copied into the wanted location.
- startDap(config: NatlinkConfig) bool[source]
Starts DAP (Debug Adapter Protocol) if there a DAP port specified in the config object. returns True if the dap was started.
Natlink will startDap automatically if configured in the run method below. If you need to start the DAP sooner, edit your code to make a call to startDap. Similarly, if you want to start the DAP later, call startDap. You can call it from your grammar or anywhere else.