You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to create a template for my config file using confuse but have trouble understanding how this works. Unfortunately I can't find much about it in the docs.
I am have the following sample in MyApp.py:
As you can see the first print statement doesn't actually resolve the filename, even though the template specifies it as a filename, but the second and third version do resolve it correctly. Since I want my application to be ignorant wrt confuse, I just want it to use config['api']['token_file'] without having to worry about the templates. So is there a way to have confuse recursively resolve the template types when I call config.get(template), so the first print statement also resolves as I was expecting?
The text was updated successfully, but these errors were encountered:
I think the main thing to realize is that the line config.get(template) isn't doing anything—it doesn't change anything about the configuration. get is really just a getter and won't affect further calls.
You can do config.get(template)['api']['token_file'] and that should do what you expect, equivalent to config["api"]["token_file"].as_filename(). So to directly answer your question, you can store the result of config.get(template), which is just a normal, completely standard Python dict-of-dicts data structure and use that.
I am trying to create a template for my config file using confuse but have trouble understanding how this works. Unfortunately I can't find much about it in the docs.
I am have the following sample in
MyApp.py
:If I then put the following in
~/.config/MyApp/config.yaml
This is the output of MyApp.py:
As you can see the first print statement doesn't actually resolve the filename, even though the template specifies it as a filename, but the second and third version do resolve it correctly. Since I want my application to be ignorant wrt confuse, I just want it to use
config['api']['token_file']
without having to worry about the templates. So is there a way to have confuse recursively resolve the template types when I callconfig.get(template)
, so the first print statement also resolves as I was expecting?The text was updated successfully, but these errors were encountered: