Skip to content
Snippets Groups Projects

Dump config file

Merged Theophile GENTILHOMME requested to merge dumpconfig into master
Files
7
@@ -166,15 +166,15 @@ class ConfigCommand(click.Command):
self.config_argument_name = config_argument_name
self.entry_point_group = entry_point_group
# Augment help for the config file argument
self.extra_help = '''\n\n[{CONFIG}]... Configuration
files. It is possible to pass one or several Python files (or names of
``{entry_point_group}`` entry points or module names) which contain the
parameters listed below as Python variables. The options through the
command-line (see below) will override the values of configuration files. You
can run this command with ``<COMMAND> -H example_config.py`` to create a
template config file.'''.format(CONFIG=config_argument_name,
entry_point_group=entry_point_group)
help = (help or '') + self.extra_help
self.extra_help = '''\n\nIt is possible to pass one or several Python files
(or names of ``{entry_point_group}`` entry points or module names) as {CONFIG}
arguments to the command line which contain the parameters listed below as
Python variables. The options through the command-line (see below) will
override the values of configuration files. You can run this command with
``<COMMAND> -H example_config.py`` to create a template config
file.'''.format(CONFIG=config_argument_name,
entry_point_group=entry_point_group)
help = (help or '').rstrip() + self.extra_help
# kwargs['help'] = help
click.Command.__init__(
self, name, context_settings=context_settings, callback=callback,
@@ -188,6 +188,7 @@ template config file.'''.format(CONFIG=config_argument_name,
help="Name of the config file to be generated")(self)
def is_resource(self, param, ctx):
"""Checks if the param is an option and is also in the current context."""
return (param.name in ctx.params and
param.name != 'dump_config' and
isinstance(param, click.Option))
@@ -383,3 +384,11 @@ def log_parameters(logger_handle):
# and is useful (but not necessary so works on Python 2 too).
for k, v in ctx.params.items():
logger_handle.debug('%s: %s', k, v)
def assert_click_runner_result(result, exit_code=0):
"""Helper for asserting click runner results"""
m = ("Click command exited with code `{}' and exception:\n{}"
"\nThe output was:\n{}")
m = m.format(result.exit_code, result.exception, result.output)
assert result.exit_code == exit_code, m
Loading