Repository Configuration

class dnf.repodict.RepoDict

Dictionary mapping repository IDs to the respective dnf.repo.Repo objects. Derived from the standard dict.


Add a Repo to the repodict.

add_new_repo(repoid, conf, baseurl=(), \*\*kwargs)

Initialize new Repo object and add it to the repodict. It requires repoid (string), and dnf.conf.Conf object. Optionally it can be specified baseurl (list), and additionally key/value pairs from kwargs to set additional attribute of the Repo object. Variables in provided values (baseurl or kwargs) will be automatically substituted using conf.substitutions (like $releasever, …). It returns the Repo object.


Return a list of all contained repositories.

See the note at get_matching() for special semantics of the returned object.


Enable debug repos corresponding to already enabled binary repos.


Enable source repos corresponding to already enabled binary repos.


Return a list of repositories which ID matches (possibly globbed) key or an empty list if no matching repository is found.

The returned list acts as a composite, transparently forwarding all method calls on itself to the contained repositories. The following thus disables all matching repos:

import dnf

base = dnf.Base()

repos = base.repos.get_matching('*-debuginfo')

Return an iterator over all enabled repos from the dict.


Return index of the first invalid character in the repo_id or None if all characters are valid. This function is used to validate the section names in .repo files.

class dnf.repo.Metadata

Represents the metadata files.


Boolean. True if the metadata was loaded from the origin, False if it was loaded from the cache.

class dnf.repo.Repo

Repository object used for metadata download. To configure it properly one has to give it either metalink, mirrorlist or baseurl parameter. This object has attributes corresponding to all configuration options from both “Repo Options” and “Options for both [main] and Repo” sections.


Some Repo attributes have non-native Python types. Duck typing works (objects have identical behavior), but isinstance() and type() doesn’t work as expected because of different types. For example excludepkgs and includepkgs return a VectorString, which is s SWIG wrapper on top of underlying libdnf C++ code.


ID of this repo. This attribute is read-only.


If load() has been called and succeeded, this contains the relevant Metadata instance.


Directory where packages of a remote repo will be downloaded to. By default it is derived from cachedir in __init__() but can be overridden by assigning to this attribute.


The path to configuration file of the class.

__init__(name=None, parent_conf=None)

Init repository with ID name and the parent_conf which an instance of dnf.conf.Conf holding main dnf configuration. Repository ID must be a string that can contain ASCII letters, digits, and -_.: characters.


Ask for additional repository metadata type to download. Given metadata_type is appended to the default metadata set when repository is downloaded.


Disable the repository. Repositories are enabled by default.


Print repository configuration, including inherited values.


Enable the repository (the default).


Return user defined http headers. Return tuple of strings.


Return contents of the repository’s metadata file of the given metadata type. Contents of compressed files are returned uncompressed.


Return path to the file with downloaded repository metadata of given type.


Load the metadata of this repository. Will try to use local cache if possible and initiate and finish download if not. Returns True if fresh metadata has been downloaded and False if cache was used. Raises dnf.exceptions.RepoError if the repo metadata could not be obtained.


Set new user headers and rewrite existing ones. headers must be an instance of tuple of strings or list of strings.

set_or_append_opt_value(name, value_string, priority=PRIO_RUNTIME).

For standard repository options, sets the value of the option if the priority is equal to or higher than the current priority. For “append” options, appends the values parsed from value_string to the current list of values. If the first parsed element of the list of values is empty and the priority is equal to or higher than the current priority, the current list is replaced with the new values. If the priority is higher than the current priority, the current priority is increased to the priority. Raises dnf.exceptions.ConfigError if the option with the given name does not exist or value_string contains an invalid value or not allowed value.


Set the download progress reporting object for this repo during load(). progress must be an instance of dnf.callback.DownloadProgress.