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

Adding the capability to enumerate sections #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

stefkohub
Copy link

@stefkohub stefkohub commented Dec 6, 2021

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.

…iting. If set to false it is adding a prefix with three zero-filled digits. The number is increased per each new section parsed. Set to true for backward compatibility.
@easco
Copy link
Owner

easco commented Dec 6, 2021

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?

@stefkohub
Copy link
Author

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.

@easco
Copy link
Owner

easco commented Dec 11, 2021

If you're looking at a separate project that already had ini files then I was wrong.

@stefkohub
Copy link
Author

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.

@sthompson-crestron
Copy link

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.

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

Successfully merging this pull request may close these issues.

None yet

3 participants