From 439425fc42e76a8d389b9211a42c85bb78b71411 Mon Sep 17 00:00:00 2001 From: Thomas Quinot Date: Thu, 15 Feb 2018 22:25:29 +0100 Subject: [PATCH] Improve documentation for inject_parser_options Provide a docstring, and explain necessity of using ** syntax. --- certbot/plugins/dns_common.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/certbot/plugins/dns_common.py b/certbot/plugins/dns_common.py index 1ab18c83f..580de8dfe 100644 --- a/certbot/plugins/dns_common.py +++ b/certbot/plugins/dns_common.py @@ -56,7 +56,31 @@ class DNSAuthenticator(common.Plugin): @classmethod def inject_parser_options(cls, parser, name): + """Set up argument parsing for this DNS plugin. + + This is called by the plugin management framework to set up + the argument parser. + + :param ArgumentParser parser: (Almost) top-level CLI parser. + :param str name: Unique plugin name. + """ + + # The inherited method will call add_parser_arguments to set up + # the parser of each argument. + super(DNSAuthenticator, cls).inject_parser_options(parser, name) + + # Create an additional entry in the parser namespace for the + # override-challenge map. This is an initiallyt empty dict associating + # each requested certificate domain with the corresponding challenge + # override (see help for --dns--override-challenge). + + # Use set_default to provide this dict as an entry in the namespace + # object returned by the parser. Note that set_default uses keyword + # arguments to determine the name of the entry to be set, and + # here the name is dynamically computed (depending on the plugin + # name), which is why we need to use ** syntax. + challenge_map_opt = common.dest_namespace(name) + "override_challenge_map" parser.set_defaults(**{challenge_map_opt: {}}) # pylint: disable=star-args