configparser_ex
configparser_ex copied to clipboard
Adding the capability to enumerate sections
Hi, I think your project is quite useful. I see the parsing is treating multiple sections with the same name as a sort of multiple instances of the same paragraph. This means that in case you have:
` [Simple Values] key=value spaces in keys=allowed
[Simple Values]
spaces in values=allowed as well
spaces around the delimiter = obviously
you can also use : to delimit keys from values`
The parse result will contain only one "Simple Values" section with the merge of two key/value pairs. I need something a little different. In the aforementioned case I need the parse result will contain 001_Simple Values and 002_Simple Values sections. Hence I added the code in this pull request. I know that it could be implemented in a better way and there is may things we can improve. Maybe we can talk about it here. First of all: are you interested in this improvement?
P.S. Please be patient I'm still learning how to code in Elixir.
I'm hesitant to change the behavior because this library is designed to mimic the behavior of the Python configparser module. With the default settings of that module, if you add duplicate sections the parser will throw an exception. You can get around that by creating a parser with the setting 'strict=False' but then the behavior of the Python parser will match the behavior of the Elixir version.
The goal of this project is to help with environments where there were existing configparser files and developers needed Elixir support for them. It seems like you're creating new applications. Does Elixir's "Config" module not satisfy what you need?
Hi, thank you for your reply. Maybe I need to study a bit more but it seems to me that the Elixir Config module is accepting exs-like syntax. I need to parse Yolo Darknet config files which are quite similar to the ones parsed by configparser.
If you're looking at a separate project that already had ini files then I was wrong.
Thank you again for your answer. But I cannot understand whether you are interested in merging this pull request or not. Can you please explain me more? :) Thank you.
No. I don't want to merge this pull request. While I have no objections to the functionality per se, it is not functionality found in the configparser library that this project is meant to duplicate.