def getNatlinkIni(self): """return the path of the natlink.ini file """ path = loader.config_locations()[0] if not os.path.isfile(path): raise OSError(f'getNatlinkIni: not a valid file: "{path}"') return path
def test_config_locations(): """tests the lists of possible config_locations and of valid_locations """ locations = loader.config_locations() assert len(locations) == 2 valid_locations = loader.valid_config_locations() assert len(valid_locations) > 0 assert os.path.isfile(valid_locations[0])
def get_check_config_locations(self): """check the location/locations as given by the loader """ config_path, fallback_path = loader.config_locations() if not isfile(config_path): config_dir = Path(config_path).parent if not config_dir.is_dir(): config_dir.mkdir(parents=True) shutil.copyfile(fallback_path, config_path) return config_path
try: from natlink import loader except ModuleNotFoundError: print('Natlink is not enabled, module natlink and/or natlink.loader cannot be found\n\texit natlinkstatus.py...') sys.exit() from natlink import config from natlink import singleton import natlink ## setup a natlinkmain instance, for getting properties from the loader: ## note, when loading the natlink module via Dragon, you can call simply: # # # natlinkmain = loader.NatlinkMain() ## setting up Logger and Config is needed, when running this for test: Logger = logging.getLogger('natlink') Config = config.NatlinkConfig.from_first_found_file(loader.config_locations()) natlinkmain = loader.NatlinkMain(Logger, Config) # the possible languages (for get_language), now in loader shiftKeyDict = {"nld": "Shift", "enx": 'shift', "fra": "maj", "deu": "umschalt", "ita": "maiusc", "esp": "may\xfas"} thisDir, thisFile = os.path.split(__file__) class NatlinkStatus(metaclass=singleton.Singleton): """this class holds the Natlink status functions.