Dear all,
I would like to propose the following feature in doit
(I have to say that I am a doit
newbie I might have misunderstood something here).
I basically would like to contribute to "global vars" from a doit.cfg
file.
By that, I mean that the following should be equivalent:
doit broker_host=... broker_token=...
[GLOBAL]
broker_host = ...
broker_token = ...
A better proposal would be to use a different name for the init section, maybe the [CONFIG]
tag could be a good fit.
Describe alternatives you've considered
I am currently working around this limition by using th [task:<task-name]
feature of doit.cfg
.
My code then includes the following function wrapper:
def get_task_option(task, key):
"""Get the key option from the input task object.
Tries to task.cfg_values.get first, task.options.get second and
doit.get_var third.
Return the value if something is found or raises ValueError if not.
"""
key_with_underscore = key.replace("-", "_")
cfg_value = task.cfg_values.get(key_with_underscore) if task.cfg_values else None
cli_value = task.options.get(key_with_underscore) if task.options else None
global_value = doit.get_var(key)
if cfg_value is not None:
return cfg_value
elif cli_value is not None:
return cli_value
elif global_value is not None:
return global_value
else:
raise ValueError(f"Missing required parameter '{key}'")
This effectively makes the params global.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too