This library provides an object-oriented interface to get information out of dnf/yum repositories.
Import the Repo class from the module.
>>> from repomd import Repo
Create a repo instance from the baseurl of the repo.
>>> repo = Repo('http://mirror.centos.org/centos/7/os/x86_64')
Optionally, you can delay loading of the repo metadata.
>>> repo = Repo('http://mirror.centos.org/centos/7/os/x86_64', lazy=True)
>>> repo.load()
The length of the repo object indicates the number of packages in the repo.
>>> len(repo)
9591
Find a package.
>>> repo.find('openssl-libs')
<Package: "openssl-libs-1:1.0.2k-8.el7.x86_64">
Find all packages.
>>> repo.findall('openssl-libs')
[<Package: "openssl-libs-1:1.0.2k-8.el7.i686">, <Package: "openssl-libs-1:1.0.2k-8.el7.x86_64">]
Iterate through packages in the repo.
>>> for package in repo:
... print(package.name)
389-ds-base
389-ds-base-devel
389-ds-base-libs
(and so on)