Blame doc/api_conf.rst

Packit Service 21c75c
..
Packit Service 21c75c
  Copyright (C) 2014-2018 Red Hat, Inc.
Packit Service 21c75c
Packit Service 21c75c
  This copyrighted material is made available to anyone wishing to use,
Packit Service 21c75c
  modify, copy, or redistribute it subject to the terms and conditions of
Packit Service 21c75c
  the GNU General Public License v.2, or (at your option) any later version.
Packit Service 21c75c
  This program is distributed in the hope that it will be useful, but WITHOUT
Packit Service 21c75c
  ANY WARRANTY expressed or implied, including the implied warranties of
Packit Service 21c75c
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
Packit Service 21c75c
  Public License for more details.  You should have received a copy of the
Packit Service 21c75c
  GNU General Public License along with this program; if not, write to the
Packit Service 21c75c
  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
Packit Service 21c75c
  02110-1301, USA.  Any Red Hat trademarks that are incorporated in the
Packit Service 21c75c
  source code or documentation are not subject to the GNU General Public
Packit Service 21c75c
  License and may only be used or replicated with the express permission of
Packit Service 21c75c
  Red Hat, Inc.
Packit Service 21c75c
Packit Service 21c75c
===============
Packit Service 21c75c
 Configuration
Packit Service 21c75c
===============
Packit Service 21c75c
Packit Service 21c75c
Configurable settings of the :class:`dnf.Base` object are stored into a :class:`dnf.conf.Conf` instance. The various options are described here.
Packit Service 21c75c
Packit Service 21c75c
.. class:: dnf.conf.Conf
Packit Service 21c75c
Packit Service 21c75c
    This object has attributes corresponding to all configuration options from both :ref:`"[main] Options" <conf_main_options-label>` and :ref:`"Options for both [main] and Repo" <conf_main_and_repo_options-label>` sections. For example setting a proxy to access all repositories::
Packit Service 21c75c
Packit Service 21c75c
        import dnf
Packit Service 21c75c
Packit Service 21c75c
        base = dnf.Base()
Packit Service 21c75c
        conf = base.conf
Packit Service 21c75c
        conf.proxy = "http://the.proxy.url:3128"
Packit Service 21c75c
        conf.proxy_username = "username"
Packit Service 21c75c
        conf.proxy_password = "secret"
Packit Service 21c75c
        base.read_all_repos()
Packit Service 21c75c
        base.fill_sack()
Packit Service 21c75c
Packit Service 21c75c
Packit Service 21c75c
  .. attribute:: get_reposdir
Packit Service 21c75c
Packit Service 21c75c
    Returns the value of the first valid reposdir or if unavailable the value of created reposdir (string)
Packit Service 21c75c
Packit Service 21c75c
  .. attribute:: substitutions
Packit Service 21c75c
Packit Service 21c75c
    An instance of :class:`dnf.conf.substitutions.Substitutions` class. A mapping of substitutions used in repositories' remote URL configuration. The commonly used ones are:
Packit Service 21c75c
Packit Service 21c75c
    ==========     ============================================== ============
Packit Service 21c75c
    key            meaning                                        default
Packit Service 21c75c
    ==========     ============================================== ============
Packit Service 21c75c
    arch           architecture of the machine                    autodetected
Packit Service 21c75c
    basearch       the architecture family of the current "arch"  autodetected
Packit Service 21c75c
    releasever     release name of the system distribution        ``None``
Packit Service 21c75c
    ==========     ============================================== ============
Packit Service 21c75c
Packit Service 21c75c
    :func:`dnf.rpm.detect_releasever` can be used to detect the ``releasever`` value.
Packit Service 21c75c
Packit Service 21c75c
    Following example shows recommended method how to override autodetected architectures::
Packit Service 21c75c
Packit Service 21c75c
        import dnf
Packit Service 21c75c
        import hawkey
Packit Service 21c75c
Packit Service 21c75c
        arch = hawkey.detect_arch()
Packit Service 21c75c
        base = dnf.Base()
Packit Service 21c75c
        base.conf.substitutions['arch'] = arch
Packit Service 21c75c
        base.conf.substitutions['basearch'] = dnf.rpm.basearch(arch)
Packit Service 21c75c
        base.fill_sack()
Packit Service 21c75c
        ...
Packit Service 21c75c
Packit Service 21c75c
Packit Service 21c75c
  .. method:: exclude_pkgs(pkgs)
Packit Service 21c75c
Packit Service 21c75c
    Exclude all packages in the `pkgs` list from all operations.
Packit Service 21c75c
Packit Service 21c75c
  .. method:: prepend_installroot(option)
Packit Service 21c75c
Packit Service 21c75c
    Prefix config option named `option` with :attr:`installroot`.
Packit Service 21c75c
Packit Service 21c75c
  .. method:: read(filename=None)
Packit Service 21c75c
Packit Service 21c75c
    Read configuration options from the ``main`` section in `filename`. Option values not present there are left at their current values. If `filename` is ``None``, :attr:`config_file_path` is used. Conversely, the configuration path used to load the configuration file that was used is stored into :attr:`config_file_path` before the function returns.
Packit Service 21c75c
Packit Service 21c75c
  .. method:: dump()
Packit Service 21c75c
Packit Service 21c75c
    Print configuration values, including inherited values.
Packit Service 21c75c
Packit Service 21c75c
  .. method:: write_raw_configfile(filename, section_id, substitutions, modify)
Packit Service 21c75c
Packit Service 21c75c
    Update or create config file. Where `filename` represents name of config file (.conf or .repo); `section_id`
Packit Service 21c75c
    represents id of modified section (e.g. main, fedora, updates); `substitutions` represents an instance of
Packit Service 21c75c
    base.conf.substitutions; `modify` represents dict of modified options.
Packit Service 21c75c
Packit Service 21c75c
Packit Service 21c75c
.. class:: dnf.conf.substitutions.Substitutions
Packit Service 21c75c
Packit Service 21c75c
  .. method:: update_from_etc(installroot, varsdir=("/etc/yum/vars/", "/etc/dnf/vars/"))
Packit Service 21c75c
Packit Service 21c75c
    Read user-defined variables values from variable directories. See :ref:`variable files <varfiles-label>` in Configuration reference.