From f2b071f8f40e985aa717af1ac72dad209cc85a99 Mon Sep 17 00:00:00 2001 From: Brad Warren Date: Thu, 4 Apr 2019 23:54:43 -0700 Subject: Don't search for plugins once for each config item (#6917) --- certbot/storage.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/certbot/storage.py b/certbot/storage.py index d0bc36c08..48587ba40 100644 --- a/certbot/storage.py +++ b/certbot/storage.py @@ -238,16 +238,17 @@ def _write_live_readme_to(readme_path, is_base_dir=False): "certificates.\n".format(prefix=prefix)) -def _relevant(option): +def _relevant(namespaces, option): """ Is this option one that could be restored for future renewal purposes? + + :param namespaces: plugin namespaces for configuration options + :type namespaces: `list` of `str` :param str option: the name of the option :rtype: bool """ from certbot import renewal - plugins = plugins_disco.PluginsRegistry.find_all() - namespaces = [plugins_common.dest_namespace(plugin) for plugin in plugins] return (option in renewal.CONFIG_ITEMS or any(option.startswith(namespace) for namespace in namespaces)) @@ -262,10 +263,13 @@ def relevant_values(all_values): :rtype dict: """ + plugins = plugins_disco.PluginsRegistry.find_all() + namespaces = [plugins_common.dest_namespace(plugin) for plugin in plugins] + rv = dict( (option, value) for option, value in six.iteritems(all_values) - if _relevant(option) and cli.option_was_set(option, value)) + if _relevant(namespaces, option) and cli.option_was_set(option, value)) # We always save the server value to help with forward compatibility # and behavioral consistency when versions of Certbot with different # server defaults are used. -- cgit v1.2.3