make add_domain more useful

This commit is contained in:
Brad Warren
2016-04-01 13:51:26 -07:00
parent ca7049dabc
commit d3fa0dd222
+15 -6
View File
@@ -876,20 +876,29 @@ class WebrootPathProcessor(argparse.Action): # pylint: disable=missing-docstrin
args.webroot_path.append(webroot) args.webroot_path.append(webroot)
def add_domain(args_or_config, domain): def add_domains(args_or_config, domains):
"""Registers a new domain to be used during the current client run. """Registers new domains to be used during the current client run.
If all domains in domain have been registered, this function has no Domains are not added to the list of requested domains if they have
effect. already been registered.
:param args_or_config: parsed command line arguments :param args_or_config: parsed command line arguments
:type args_or_config: argparse.Namespace or :type args_or_config: argparse.Namespace or
configuration.NamespaceConfig configuration.NamespaceConfig
:param str domain: one or more comma separated domains :param str domain: one or more comma separated domains
:returns: domains after they have been normalized and validated
:rtype: `list` of `str`
""" """
args_or_config.domains.extend(le_util.enforce_domain_sanity(d.strip()) validated_domains = []
for d in domain.split(",") if d not in args_or_config.domains) for domain in domains.split(","):
domain = le_util.enforce_domain_sanity(domain.strip())
validated_domains.append(domain)
if domain not in args_or_config.domains:
args_or_config.domains.append(domain)
return validated_domains
def process_domain(args_or_config, domain_arg, webroot_path=None): def process_domain(args_or_config, domain_arg, webroot_path=None):