def load() -> None: """Load plugins defined. If no plugins are passed to the function all active plugins are loaded. Args: plugins: Plugin names to load. """ _logger.debug("Loading plugins...") sys.path.insert(0, _app_plugin_directory) sys.path.insert(0, _user_plugin_directory) app_plugins = _get_plugins(_app_plugin_directory) _logger.debug("Available app plugins: %s", quotedjoin(app_plugins)) user_plugins = _get_plugins(_user_plugin_directory) _logger.debug("Available user plugins: %s", quotedjoin(user_plugins)) for plugin, info in _plugins.items(): if plugin in app_plugins: _load_plugin(plugin, info, _app_plugin_directory) elif plugin in user_plugins: _load_plugin(plugin, info, _user_plugin_directory) else: _logger.error( "Unable to find plugin '%s', ignoring.\n" " Available app plugins: %s\n" " Available user plugins: %s\n" " User plugin directory: '%s'", plugin, quotedjoin(app_plugins), quotedjoin(user_plugins), _user_plugin_directory, ) _logger.debug("Plugin loading completed")
def _read_plugins(pluginsection): """Set plugins from configuration file as requested plugins. Args: pluginsection: PLUGINS section in the config file. """ _logger.debug("Plugins in config: %s", quotedjoin(pluginsection)) plugins.add_plugins(**pluginsection)
def check(self) -> None: """Checks for possible clashes and logs warnings.""" if self.key and self.children: hidden: List[str] = [] for child in self.children.values(): hidden.extend(key for key, _ in child) _logger.warning("%s hides longer keys: %s", self.key, quotedjoin(hidden)) for child in self.children.values(): child.check()
def __init__(self, *qtargs: str) -> None: """Initialize the main Qt application. Args: qtargs: Arguments passed directly to the QApplication. """ _logger.debug("Passing %s to qt", utils.quotedjoin(qtargs)) super().__init__([vimiv.__name__, *qtargs]) self.setApplicationVersion(vimiv.__version__) self.setDesktopFileName(vimiv.__name__) self._set_icon()
def _split_prefix(self, text): """Remove prefix from text for command processing. Returns: prefix: One of PREFIXES. command: Rest of the text stripped from whitespace. """ prefix, command = text[0], text[1:] if prefix not in self.PREFIXES: possible = utils.quotedjoin(self.PREFIXES) raise ValueError(f"Unknown prefix '{prefix}', possible values: {possible}") command = command.strip() return prefix, command
def test_quotedjoin(iterable, joinchar): iterable = list(iterable) quoted_iterable = ("'" + str(elem) + "'" for elem in iterable) expected = joinchar.join(quoted_iterable) assert expected == utils.quotedjoin(iterable, joinchar=joinchar)