Blame doc/api_conf.rst

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