You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This would allow a piece of code to iterate over the existing attributes.
Currently it's not even possible to list the registered attributes for a given section type, so if some code wanted to enumerate all the attributes e.g. in a loop, it'd need to maintain a list of attributes, while this information is readily available for the parser (both the possible (via ConfiguredParsers), and the actually set attributes (via Parsers))
(Happily) wiling to contribute code if this feature makes sense.
The text was updated successfully, but these errors were encountered:
we have no objections to adding this to the package
there are some hints how this could be achieved in writer function where we go over all sections and attributes
(Happily) wiling to contribute code if this feature makes sense.
we can add it to the list, but if you are willing to contribute, that is most welcomed!
Hi @oktalz.
I created a PR. I tried to not complicate things and keep it simple, might be too simple.
The change is not affecting generated code and (i think) it's not disturbing any parts of the existing interface or behaviour.
Possible discussion points
onlyExisting
I added a flag to the new method, to allow the caller to decide if they are interested in all the possible attributes in that section, or only the ones that are existing in the sense that they are set so will cause lines in the final result.
I see value in both, but I think listing the existing is more important (to our use-case deinitely).
So I can remove the existingOnly flag if you think it clutters the interface.
extra.Section
Theextra.Section parsers gave me a bit of a thinking, i'm unsure if there's anything in there that's relevant for attribute listing, but in the end I concluded that they are something special, that are as the name say extra, and strictly not part of the block's definition, not directly associated with lines in the serialised config, they appear more to be information about related blocks.
E.g. the default_backend line seems to cause the backend extra section to contain data about the referenced backend block.
Assuming
Proposal
It would be a useful feature, to be able to list all the set attributes in a given section
E.g.
This would allow a piece of code to iterate over the existing attributes.
Currently it's not even possible to list the registered attributes for a given section type, so if some code wanted to enumerate all the attributes e.g. in a loop, it'd need to maintain a list of attributes, while this information is readily available for the parser (both the possible (via ConfiguredParsers), and the actually set attributes (via Parsers))
(Happily) wiling to contribute code if this feature makes sense.
The text was updated successfully, but these errors were encountered: