fix: dnf.cli.util.* leaks file handles.

Plus a bunch of de-linting and cosmetics.