Satiate the pylint daemons

This commit is contained in:
Peter Eckersley
2015-06-16 12:46:37 -07:00
parent c70bce8b7a
commit 8dc9cc67d9
+13 -11
View File
@@ -231,25 +231,26 @@ def config_help(name, hidden=False):
else:
return interfaces.IConfig[name].__doc__
class SilentParser:
class SilentParser(object):
"""An a mini parser wrapper that doesn't print help for its
arguments... this one is just needed to the use of callbacks to define
arguments within plugins"""
def __init__(self, parser):
self.parser = parser
def add_argument(self, *args, **kwargs):
"""Wrap, but silence help"""
kwargs["help"] = argparse.SUPPRESS
self.parser.add_argument(*args, **kwargs)
HELP_TOPICS = ["all", "security", "paths", "automation", "testing"]
class HelpfulArgumentParser:
class HelpfulArgumentParser(object):
"""This class wraps argparse, adding the ability to make --help less
verbose, and request help on specific subcategories at a time, eg
'letsencrypt --help security' for security options."""
def __init__(self, args, plugins):
self.args = args
plugin_names = [name for name, p in plugins.iteritems()]
plugin_names = [name for name, _p in plugins.iteritems()]
self.help_topics = HELP_TOPICS + plugin_names
self.parser = configargparse.ArgParser(
description=__doc__,
@@ -259,7 +260,7 @@ class HelpfulArgumentParser:
self.silent_parser = SilentParser(self.parser)
h1 = self.prescan_for_flag("-h", self.help_topics)
h2 = self.prescan_for_flag("--h", self.help_topics)
h2 = self.prescan_for_flag("--help", self.help_topics)
assert max(True, "a") == "a", "Gravity changed direction"
help_arg = max(h1, h2)
self.visible_topics = self.determine_help_topics(help_arg)
@@ -280,7 +281,7 @@ class HelpfulArgumentParser:
nxt = self.args[pos + 1]
if nxt in possible_arguments:
return nxt
except:
except IndexError:
pass
return True
@@ -290,8 +291,8 @@ class HelpfulArgumentParser:
documented'."""
if topic and self.visible_topics[topic]:
g = self.groups[topic]
g.add_argument(*args, **kwargs)
group = self.groups[topic]
group.add_argument(*args, **kwargs)
else:
kwargs["help"] = argparse.SUPPRESS
self.parser.add_argument(*args, **kwargs)
@@ -303,14 +304,16 @@ class HelpfulArgumentParser:
group."""
if self.visible_topics[topic]:
#print "Adding visible group " + topic
g = self.parser.add_argument_group(topic, **kwargs)
self.groups[topic] = g
return g
group = self.parser.add_argument_group(topic, **kwargs)
self.groups[topic] = group
return group
else:
#print "Invisible group " + topic
return self.silent_parser
def add_plugin_args(self, plugins):
"""Let each of the plugins add its own command line arguments, which
may or may not be displayed as help topics."""
# TODO: plugin_parser should be called for every detected plugin
for name, plugin_ep in plugins.iteritems():
parser_or_group = self.add_group(name, description=plugin_ep.description)
@@ -458,7 +461,6 @@ def _paths_parser(helpful):
help=config_help("chain_path"))
add("paths", "--renewer-config-file", default=flag_default("renewer_config_file"),
help=config_help("renewer_config_file"))
add("paths", "-s", "--server", default=flag_default("server"),
help=config_help("server"))