I am trying to create a tool to inspect changes in updated packages. DNF doesn’t provide any JSON or CSV or output templates, and the best output I could find is dnf check-update -q.
The output is not ideal. First there is an empty string, and then a specially artcrafted obsoleted section.
dnf is written in Python, so it effectively is a Python API. If you write Python code using the dnf module, you can pretty much do anything command-line dnf does, and output it in whatever format you like. (If you even need to output it at all, since working in Python there’d be no need to bother.)
So, for instance, the dnf check-update command is implemented in dnf.cli.commands — it’s actually the CheckUpdateCommand class in the __init__py file, which is probably located at:
Mmm, probably not. But a Python script that output results in e.g. JSON, using the dnf package APIs and the json module (part of the Python3 standard lib), wouldn’t be too painful to write.
And if you are/were planning (or willing) to call command-line dnf and parse its output, also no different.
I tried once writing Python script to make queries like this and it was painful. It was not some well formatted OpenAPI spec, but almost one to one wrapper over underlying C libraries.
Parsing output doesn’t require sudo installation of plugin. The ideal case is if dnf command line provided generalized query interface to output desired CSV or JSON using Go templates.