Commit 42108fc5 authored by Theophile GENTILHOMME's avatar Theophile GENTILHOMME

[script][click_helper] Add entries information when ResourceOptions are used

parent 66df3b55
from ..log import set_verbosity_level from ..log import set_verbosity_level
from ..config import load, mod_to_context from ..config import load, mod_to_context
from ..utils import resource_keys
import time import time
import click import click
import logging import logging
...@@ -171,11 +172,16 @@ def dump_config(command, params, ctx): ...@@ -171,11 +172,16 @@ def dump_config(command, params, ctx):
continue continue
if is not None: if is not None:
config_file.write('## %s.\n' % config_file.write('## %s.\n' %
dflt='' if (param.required or False) else \ dflt='' if param.required or (isinstance(param, ResourceOption) and
param.real_required) else \
"[default: {}]".format(param.default) "[default: {}]".format(param.default)
config_file.write( config_file.write(
'## Option: %s %s\n' % (', '.join(param.opts), dflt) '## Option: %s %s\n' % (', '.join(param.opts), dflt)
) )
if isinstance(param, ResourceOption) and param.entry_point_group is not\
config_file.write("## registered entries are: {}\n".format(
config_file.write('# %s = %s\n\n' % (, config_file.write('# %s = %s\n\n' % (,
str(ctx.params[]))) str(ctx.params[])))
...@@ -303,7 +309,6 @@ class ResourceOption(click.Option): ...@@ -303,7 +309,6 @@ class ResourceOption(click.Option):
while isinstance(value, basestring): while isinstance(value, basestring):
value = load([value], entry_point_group=self.entry_point_group) value = load([value], entry_point_group=self.entry_point_group)
value = getattr(value, keyword) value = getattr(value, keyword)
return value return value
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment