-
Notifications
You must be signed in to change notification settings - Fork 1
add a script to convert files to formatted TOML #14
Conversation
what exactly does that mean "except for comments"?
I'm not particularly attached to this nesting but it seemed a good idea to leave room for extension should further needs arise in the future.
Here I'm inclined to keep them. It makes it more clear when reading the data structure IMO. Also it is less error prone / explicitly marked as a certain type of entry. |
As you can see in the see sample output, the comments are turned into TOML comments. So they still are in the output file, but them being comments means they are not visible after parsing this TOML into a Python data structure. I'll remove the "audits" and keep "meta"/"digests". |
I won't do a picky review review for this - hopefully - only temporarily used script. Only the user interface concerns me a bit. The
This repetitiveness surprises me a bit. Is this really the only way to nest in TOML? |
Yup, that's really the discussion I wanted to have with this PR.
The only other way to have nested key-value pairs (besides INI-style sections) are "inline tables" like I'm using for the file meta data. They can't span more than a single-line, so that's no good. So repeating e.g. the package name all the time is unavoidable. The whole (Also, the indentation doesn't do anything, I just prefer it that way.) |
So, to be clear: we could do something like this: #### nscd ####
[nscd.'bsc#1174642'.meta]
# nss caching daemon socket. is packaged as %ghost, therefore 'appears' to be a regular file.
'/run/nscd/socket' = { type = '-', mode = '0666', owner = 'root:root' }
#### patch2mail ####
[patch2mail.'bsc#1150552'.digests]
# looks up pending zypper patches and sens them out by mail
'/etc/cron.daily/patch2mail' = 'sha256:2db3aaa7addba83e60e24fdb868dd6f353bfb76b005fd2a2fdaf079fb54fe597' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, to be clear: we could do something like this:
Looks concise, would be fine for me.
OK, I've updated the script. I've done one more change: instead of using a comment to start the section for a package, I use an empty INI-style header: [bind-chrootenv]
[bind-chrootenv.'bsc#1174642'.meta]
# Chroot duplicates of some uncritical character devices. urandom was historically packaged non-world-writable, probably to avoid the rpmlint error triggering.
'/var/lib/named/dev/null' = { type = 'c', mode = '0666', dev = '1,3', owner = 'root:root' } Somehow I thought before that wouldn't work. There can't be more than one section with the same name in a file, so at least this prevents multiple sections about a package in the same file. (Nesting isn't enforced though, so audits for a package could in theory be put into the wrong section.) |
@maltek Maybe a silly question, but have you tried using |
@marxin that works to correctly preserve the contents, but not to get nice readable formatting. |
I see. Anyway, once the |
For rpm-software-management/rpmlint#439 we need to switch to TOML. To be able to keep working without interruption this PR adds a script that converts the current JSON to decently formatted TOML. The script is a bit hacky, but it makes sure that - except for comments - the parsed TOML files are identical to the JSON input.
The output of this script are TOML files looking like this:
As far as I am concerned, we could also drop the dictionary nesting level "audits", since it's the only sub-key to the package name that exists. Technically, "digests" and "meta" are also redundant (the rpmlint check already knows which of these it expects).