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

Comments are not kept after write_to_file #77

Open
lrascao opened this issue Oct 16, 2020 · 4 comments
Open

Comments are not kept after write_to_file #77

lrascao opened this issue Oct 16, 2020 · 4 comments

Comments

@lrascao
Copy link

lrascao commented Oct 16, 2020

[a_section]
a=1
#b=1

after write_to_file is called we end up with:

[a_section]
a=1
@zonyitoo
Copy link
Owner

Yup.. Comments are not kept after parsed. Any PRs are welcome.

@lrascao
Copy link
Author

lrascao commented Oct 19, 2020

cool, could you please suggest an implementation strategy?

@zonyitoo
Copy link
Owner

zonyitoo commented Oct 19, 2020

I have no idea how to implement that gracefully, because comments may not be followed by a key-value pairs, or a section header, how to store it?

Do you know any other INI libraries that could kept comments after parsing? @lrascao

@bviktor
Copy link

bviktor commented Mar 7, 2023

I'm not familiar with rust-ini, but based on this issue alone, I assume it works by mapping the whole file on read, and flushing the whole structure into a file on write. Which will probably bite you when dealing with big files, so it may not be the best approach.

From Bash I use crudini which is in Python so prolly not much of a help, but who knows. All I know is it works just fine with comments. Basically it doesn't care about irrelevant sections in the file, or irrelevant lines in the section either. It touches only the parts you tell it touch.

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