Comments (8)
Hello,
Currently, when serializing, configparser-rs always uses unix line endings ('\n', lf). On the python side, configparser will use the appropriate line ending depending on the platform it's currently running on (crlf on windows, lf everywhere else).
I think it'd be nice if configparser would allow configuring the line endings being used, e.g. add an enum to IniDefaults to let the user chose between Lf and Crlf line endings.
Good point, I will look into this a bit more and make a decision.
from configparser-rs.
Hello,
Currently, when serializing, configparser-rs always uses unix line endings ('\n', lf). On the python side, configparser will use the appropriate line ending depending on the platform it's currently running on (crlf on windows, lf everywhere else).
I think it'd be nice if configparser would allow configuring the line endings being used, e.g. add an enum to IniDefaults to let the user chose between Lf and Crlf line endings.
Thought about this a bit more and I'm honestly not sure how useful this would be. Rust does not support optional parameters like other languages, so the only way would be an Option
that would break compat with the current API - or extending IniDefault
which is already quite encompassing of features.
from configparser-rs.
For us this is a needed feature, on windows we want to use CRLF line endings.
I see several possibilities for this feature:
- do not expose any options, but change behavior to use CRLF on windows, LF anywhere else. This is a breaking change, but aligns on python's behavior afaict
- expose a new option in IniDefault to configure the line endings. Yes it adds yet another parameters in this object, but since #22, this is not a breaking change, and adding more fields to this object does not impact the end user.
- do both: expose an option, but by default decide depending on the platform
- last option if you do not want to add more fields to IniDefault would be to add a
set_line_endings
toIni
, though it looked like you designed all parameters to be settable through the IniDefault struct.
Also, #22 was done to allow adding more parameters to IniDefault without breaking the API, so not wanting to bloat IniDefault more goes a bit in another direction design-wise
from configparser-rs.
For us this is a needed feature, on windows we want to use CRLF line endings.
I see several possibilities for this feature:
* do not expose any options, but change behavior to use CRLF on windows, LF anywhere else. This is a breaking change, but aligns on python's behavior afaict * expose a new option in IniDefault to configure the line endings. Yes it adds yet another parameters in this object, but since [Non exhaustive IniDefault #22](https://github.com/QEDK/configparser-rs/pull/22), this is not a breaking change, and adding more fields to this object does not impact the end user. * do both: expose an option, but by default decide depending on the platform * last option if you do not want to add more fields to IniDefault would be to add a `set_line_endings` to `Ini`, though it looked like you designed all parameters to be settable through the IniDefault struct.
Also, #22 was done to allow adding more parameters to IniDefault without breaking the API, so not wanting to bloat IniDefault more goes a bit in another direction design-wise
I agree but line endings are low on the list of things that will cause things to break (on a modern version of Windows atleast). I think we can add something like this, similar to your first suggested option:
#[cfg(windows)]
const LINE_ENDING: &'static str = "\r\n";
#[cfg(not(windows))]
const LINE_ENDING: &'static str = "\n";
Edit: Upon further thought and research, most of the Windows ecosystem (i.e. VSCode really) have all adapted to using LF (including Notepad in 2018). Unless, I have an example of this breaking something somewhere, we don't really need this.
from configparser-rs.
Edit: Upon further thought and research, most of the Windows ecosystem (i.e. VSCode really) have all adapted to using LF (including Notepad in 2018). Unless, I have an example of this breaking something somewhere, we don't really need this.
This is not true in my case. At least on my product, I have lots of users on versions of windows that don't universally support CRLF line endings. For instance, I have clients using Windows Server 2016 and Windows 10 Enterprise LTSC 2016, and various versions of windows 8-8.1 (all of which still supported by microsoft). VSCode does not have the issue, but my users are very unlikely to be using VSCode to edit the ini files (and much more likely to use whatever notepad comes preinstalled on their windows machines).
Setting the line endings based on cfg
would work for me. If this is OK with you, I can submit a PR with the change.
from configparser-rs.
@roblabla @vthib alright, any one of you feel free to pick this up. thanks a lot for your patience and work 😄
from configparser-rs.
Thanks for coming back to this :) . However I see you have released 3.0.0 and marked this for 3.0.1, and the cfg
solution that I pushed is a breaking change. I'm not sure how you prefer to tackle this
from configparser-rs.
Thanks for coming back to this :) . However I see you have released 3.0.0 and marked this for 3.0.1, and the
cfg
solution that I pushed is a breaking change. I'm not sure how you prefer to tackle this
We'll go with the Pythonic approach of setting the ending per platform, it shouldn't be a breaking change as Rust fs
treats CRLF as LF when ingesting it.
from configparser-rs.
Related Issues (20)
- 2.0.0 crate contains files with a UNIX timestamp of 0, and some files are marked executable HOT 3
- Ini::load should accept a Path instead of str HOT 6
- Add spacing between sections and option to add space between key and value HOT 9
- Keys are shuffled when loading and saving a INI file HOT 7
- Migrate configparser to 2021 edition
- Support for multi-line values HOT 1
- New release with CRLF line endings and edition 2021 HOT 3
- Iterate over the keys of a section request. HOT 2
- Serde support? HOT 6
- Configparser handles CLI password managers for secure secret's storage?
- How to convert `HashMap<String, T>` to configparser ini String? HOT 1
- Add support BasicInterpolation from python configparser HOT 3
- Support sections with no keys HOT 4
- `load` or `read` without creating a clone? HOT 1
- Panic when multiline enabled due to unwrap HOT 2
- Add support for `load()`ing multiple files
- Deprecate `async-std` feature and replace with `tokio` HOT 1
- How to fetch duplicate keys in section? HOT 1
- Support for a "print()" function? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from configparser-rs.