def test_initialise(): # Assuming that initialise() # has not yet been called assert settings.read('nothing') is None assert settings.read('nothing', 'default') == 'default' settings.write('nothing', 'nothing') settings.delete('nothing') assert settings.readFile('nothing') is None settings.writeFile('nothing', 'nothing') settings.deleteFile('nothing') assert settings.filePath() is None assert settings.readAll() == {} assert settings.listFiles() == [] settings.clear() with tests.testdir() as testdir: settings.initialise(cfgid='test', cfgdir=testdir, writeOnExit=False) assert settings.settings.configID == 'test' assert settings.settings.configDir == testdir settings.write('setting', 'value') assert settings.read('setting') == 'value' assert settings.read('nothing') is None
def scanUserAddedLuts(): """Returns a list of IDs for all user-added lookup tables. """ lutFiles = fslsettings.listFiles('luts/*.lut') lutFiles = [op.basename(f) for f in lutFiles] lutIDs = [op.splitext(f)[0] for f in lutFiles] lutIDs = [m.lower() for m in lutIDs] return lutIDs
def scanUserAddedCmaps(): """Returns a list of IDs for all user-added colour maps. """ cmapFiles = fslsettings.listFiles('colourmaps/*.cmap') cmapFiles = [op.basename(f) for f in cmapFiles] cmapIDs = [op.splitext(f)[0] for f in cmapFiles] cmapIDs = [m.lower() for m in cmapIDs] return cmapIDs
def initialise(): """Calls :func:`loadPlugin` on all plugin files in the FSLeyes settings directory, and found on the ``FSLEYES_PLUGIN_PATH`` environment variable. """ pluginFiles = list(fslsettings.listFiles('plugins/*.py')) pluginFiles = [fslsettings.filePath(p) for p in pluginFiles] fpp = os.environ.get('FSLEYES_PLUGIN_PATH', None) if fpp is not None: for dirname in fpp.split(op.pathsep): pluginFiles.extend(glob.glob(op.join(dirname, '*.py'))) for fname in pluginFiles: try: loadPlugin(fname) except Exception as e: log.warning('Failed to load plugin file %s: %s', fname, e)