Skip to content

python3-libdnf to python3-libdnf5 migration #1867

Answered by kontura
JGoutin asked this question in Q&A
Discussion options

You must be logged in to vote

This prints ids and mirrors for all installed and enabled repositories.

import libdnf5

base = libdnf5.base.Base()
base.setup()
repo_sack = base.get_repo_sack()
repo_sack.create_repos_from_system_configuration()
repo_sack.load_repos(libdnf5.repo.Repo.Type_AVAILABLE)

query = libdnf5.repo.RepoQuery(base)
query.filter_enabled(True)

for repo in query:
    print(repo.get_id())
    print(repo.get_mirrors())

You can check out some details about the loading of configured repositories in https://dnf5.readthedocs.io/en/latest/tutorial/bindings/python3/repos.html.

Note that the libdnf5.repo.RepoQuery is not connected to the repoquery command on the CLI, it is a query on all known repositories (Repo

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@JGoutin
Comment options

Answer selected by JGoutin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants