Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support BasicInterpolation from python configparser #36

Open
stalkerg opened this issue Apr 3, 2023 · 3 comments
Open

Add support BasicInterpolation from python configparser #36

stalkerg opened this issue Apr 3, 2023 · 3 comments

Comments

@stalkerg
Copy link

stalkerg commented Apr 3, 2023

In the python version, we have special variables like %(here) which is very helpful for big config files, but mostly it's needed for interoperability.
https://docs.python.org/3/library/configparser.html#configparser.BasicInterpolation

@QEDK
Copy link
Owner

QEDK commented Apr 3, 2023

In the python version, we have special variables like %(here) which is very helpful for big config files, but mostly it's needed for interoperability. https://docs.python.org/3/library/configparser.html#configparser.BasicInterpolation

I see two ways to go about it, one is getter-level interpolation which is fairly easy but adds more functions, get_with_interpolation() or similar. Second is struct-level interpolation which is more useful but more complicated, similar to defaults, specify a interpolation hashmap like HashMap(String, String) and replace values at the time of parsing.

@stalkerg
Copy link
Author

stalkerg commented Apr 5, 2023

It seems like even ExtendedInterpolation is about interpolation after parsing for each value. I think get_with_interpolation can be good enough.
From a performance point, you probably want to see both ways because sometimes significant the config parsing time and sometimes how quickly you can get data. But if you can get value, it's not a big deal to cache it.

@belak
Copy link
Contributor

belak commented Apr 23, 2024

What sort of API are you hoping for? We ended up implementing it on top of the library, but it would be nice to upstream it if possible.

It does introduce new failure modes though: for our use case, we ended up ignoring invalid interpolation and just passing through the value directly, but I have to imagine some people would prefer to receive that error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants