Deltares / HYDROLIB-core

Core code around the I/O of the DHYDRO-suite
https://deltares.github.io/HYDROLIB-core/
MIT License
24 stars 4 forks source link

Add support for adding custom comment header to INI files #362

Open priscavdsluis opened 2 years ago

priscavdsluis commented 2 years ago

Is your feature request related to a problem? Please describe. Currently, it is not possible for a user to add custom header comments.

    @priscavdsluis Hi Prisca, thanks for the answer. I am specifically looking to add comments on top, so where "# written by HYDROLIB-core 0.3.0" is now located. Something like "#Values in this file are derived from DCSM-FM 3D version 20220510. The points are locations on the RMM 2D j19 extended model". So not something in the general block or behind instances, but a global comment at the top of the file. Is that also possible?

Originally posted by @veenstrajelmer in https://github.com/Deltares/HYDROLIB-core/issues/130#issuecomment-1272963902

Describe the solution you'd like

Possible technical solution Currently, In the INIModel._to_document function, a header variable is created with the content written by HYDROLIB-core <version>. Suggestion: this variable could also be class attribute that is customizable per ParsableFileModel instance.

IF the comments should also be parsed from file we need to adjust the Document.flatten function to take into account the header_comments

priscavdsluis commented 2 years ago

@arthurvd, I wonder the following: If the user is able to edit the header comment, should we also be able to read it?

Now we always write: written by HYDROLIB-core <version> to INI files. This makes sense, since it is true.

Should the header be "write-only"?