Keeping inline comments

21 views
Skip to first unread message

Andrew Wade

unread,
Jan 23, 2015, 5:35:59 AM1/23/15
to pynag-...@googlegroups.com
Hey,

I noticed the parser strips inline comments (anything after a semicolon on a line). I haven't started using pynag, but I'm looking in to it. I wouldn't want to lose existing comments if I transitioned to pynag.

What about a configurable option to keep inline comments? They could be stored as another attribute of the object and included when writing each line.

I could look in to sending a pull request, but is this sensible, as a configurable option?

Thanks.

Páll Sigurðsson

unread,
Jan 25, 2015, 4:20:15 PM1/25/15
to pynag-...@googlegroups.com
It does not make sense to have it configurable, but it does make sense to implement preservation of in-line comments, although its hard to justify the use case because outside of the example configs, which explain what each attribute does, having an in-line config almost only makes sense if you are commenting on something regarding current values, which of course is outdated by the time you change the value.

Are you already working on this? Otherwise I can take a crack at it because the parsing code it a little bit outdated to say the least.

The relevant code should be in Parsers/config_parser.py in _modify_object().

Sticking a comment preservation around line 691 seems about right.

--
You received this message because you are subscribed to the Google Groups "pynag-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pynag-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrew Wade

unread,
Jan 26, 2015, 4:28:37 AM1/26/15
to pynag-...@googlegroups.com
On Sun, 25 Jan 2015, at 09:20 PM, Páll Sigurðsson wrote:
> It does not make sense to have it configurable, but it does make sense to implement preservation of in-line comments, although its hard to justify the use case because outside of the example configs, which explain what each attribute does, having an in-line config almost only makes sense if you are commenting on something regarding current values, which of course is outdated by the time you change the value.

That's a good point about the values being out-of-date.

> Are you already working on this? Otherwise I can take a crack at it because the parsing code it a little bit outdated to say the least.

No, I'm not. On reflection, I don't have that many inline comments and
it won't be that bad if they were lost.

Thanks.
Reply all
Reply to author
Forward
0 new messages