This object has attributes corresponding to all configuration options from both “[main] Options” and “Options for both [main] and Repo” sections. For example setting a proxy to access all repositories:
import dnf base = dnf.Base() conf = base.conf conf.proxy = "http://the.proxy.url:3128" conf.proxy_username = "username" conf.proxy_password = "secret" base.read_all_repos() base.fill_sack()
Returns the value of the first valid reposdir or if unavailable the value of created reposdir (string)
An instance of
dnf.conf.substitutions.Substitutionsclass. A mapping of substitutions used in repositories’ remote URL configuration. The commonly used ones are:
key meaning default arch architecture of the machine autodetected basearch the architecture family of the current “arch” autodetected releasever release name of the system distribution
dnf.rpm.detect_releasever()can be used to detect the
Following example shows recommended method how to override autodetected architectures:
import dnf import hawkey arch = hawkey.detect_arch() base = dnf.Base() base.conf.substitutions['arch'] = arch base.conf.substitutions['basearch'] = dnf.rpm.basearch(arch) base.fill_sack() ...
Exclude all packages in the pkgs list from all operations.
Prefix config option named option with
Read configuration options from the
mainsection in filename. Option values not present there are left at their current values. If filename is
config_file_pathis used. Conversely, the configuration path used to load the configuration file that was used is stored into
config_file_pathbefore the function returns.
Print configuration values, including inherited values.
set_or_append_opt_value(name, value_string, priority=PRIO_RUNTIME).
For standard 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.ConfigErrorif the option with the given name does not exist or value_string contains an invalid value or not allowed value.
write_raw_configfile(filename, section_id, substitutions, modify)¶
Update or create config file. Where filename represents name of config file (.conf or .repo); section_id represents id of modified section (e.g. main, fedora, updates); substitutions represents an instance of base.conf.substitutions; modify represents dict of modified options.