def _relevant(option): """ Is this option one that could be restored for future renewal purposes? :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))
def relevant_values(all_values): """Return a new dict containing only items relevant for renewal. :param dict all_values: The original values. :returns: A new dictionary containing items that can be used in renewal. :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 all_values.items() 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. rv["server"] = all_values["server"] return rv
def relevant_values(all_values): """Return a new dict containing only items relevant for renewal. :param dict all_values: The original values. :returns: A new dictionary containing items that can be used in renewal. :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(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. rv["server"] = all_values["server"] return rv
def test_dest_namespace_with_dashes(self): from certbot.plugins.common import dest_namespace self.assertEqual("foo_bar_", dest_namespace("foo-bar"))
def test_dest_namespace(self): from certbot.plugins.common import dest_namespace self.assertEqual("foo_", dest_namespace("foo"))