Config.parse_arguments_options(): add hardcoded_options argument
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
56162452ac
commit
3a43b8d07d
1 changed files with 18 additions and 1 deletions
|
@ -847,7 +847,8 @@ class Config: # pylint: disable=too-many-instance-attributes
|
|||
return self.options_parser
|
||||
|
||||
def parse_arguments_options(self, argv=None, parser=None, create=True, ask_values=True,
|
||||
exit_after_created=True, execute_callback=True):
|
||||
exit_after_created=True, execute_callback=True,
|
||||
hardcoded_options=None):
|
||||
"""
|
||||
Parse arguments options
|
||||
|
||||
|
@ -862,6 +863,11 @@ class Config: # pylint: disable=too-many-instance-attributes
|
|||
creation (default: True)
|
||||
:param execute_callback: Sections's loaded callbacks will be executed only if True
|
||||
(default: True)
|
||||
:param hardcoded_options: Optional hard-coded options to set after loading arguments
|
||||
and configuration file. These options are passed using an
|
||||
list of tuple of 3 elements: the section and the option
|
||||
names and the value.
|
||||
[('section1', 'option1', value), ...]
|
||||
"""
|
||||
parser = parser if parser else self.get_arguments_parser()
|
||||
argcomplete.autocomplete(parser)
|
||||
|
@ -899,6 +905,17 @@ class Config: # pylint: disable=too-many-instance-attributes
|
|||
elif options.verbose:
|
||||
logging.getLogger().setLevel(logging.INFO)
|
||||
|
||||
if hardcoded_options:
|
||||
assert isinstance(hardcoded_options, list), (
|
||||
'hardcoded_options must be a list of tuple of 3 elements: '
|
||||
'the section and the option names and the value.')
|
||||
for opt_info in hardcoded_options:
|
||||
assert isinstance(opt_info, tuple) and len(opt_info) == 3, (
|
||||
'Invalid hard-coded option value: it must be a tuple of 3 '
|
||||
'elements: the section and the option names and the value.'
|
||||
)
|
||||
self.set(*opt_info)
|
||||
|
||||
if self.get('console', 'enabled'):
|
||||
stdout_console_handler = logging.StreamHandler(
|
||||
sys.stderr if self.get('console', 'force_stderr')
|
||||
|
|
Loading…
Reference in a new issue