Created
November 14, 2024 10:55
-
-
Save radupotop/821240916d3b93b2faf28408f1235f37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from operator import attrgetter | |
import pyalpm | |
handle = pyalpm.Handle("/", "/var/lib/pacman") | |
db = handle.get_localdb() | |
getpkgdata = attrgetter("name", "version") | |
pkgjson = json.dumps([getpkgdata(pkg) for pkg in db.pkgcache]) | |
print(pkgjson) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment