Blame doc/api_repos.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
Repository Configuration
Packit 6f3914
========================
Packit 6f3914
Packit 6f3914
Packit 6f3914
.. class:: dnf.repodict.RepoDict
Packit 6f3914
Packit 6f3914
  Dictionary mapping repository IDs to the respective :class:`dnf.repo.Repo` objects. Derived from the standard :class:`dict`.
Packit 6f3914
Packit 6f3914
  .. method:: add(repo)
Packit 6f3914
Packit 6f3914
    Add a :class:`.Repo` to the repodict.
Packit 6f3914
Packit 6f3914
  .. method:: add_new_repo(repoid, conf, baseurl=(), \*\*kwargs)
Packit 6f3914
Packit 6f3914
    Initialize new :class:`.Repo` object and add it to the repodict. It requires ``repoid``
Packit 6f3914
    (string), and :class:`dnf.conf.Conf` object. Optionally it can be specified baseurl (list), and
Packit 6f3914
    additionally key/value pairs from `kwargs` to set additional attribute of the :class:`.Repo`
Packit 6f3914
    object. Variables in provided values (``baseurl`` or ``kwargs``) will be automatically
Packit 6f3914
    substituted using conf.substitutions (like ``$releasever``, ...). It returns the :class:`.Repo`
Packit 6f3914
    object.
Packit 6f3914
Packit 6f3914
  .. method:: all()
Packit 6f3914
Packit 6f3914
    Return a list of all contained repositories.
Packit 6f3914
Packit 6f3914
    See the note at :meth:`get_matching` for special semantics of the returned object.
Packit 6f3914
Packit 6f3914
  .. method:: enable_debug_repos()
Packit 6f3914
Packit 6f3914
    Enable debug repos corresponding to already enabled binary repos.
Packit 6f3914
Packit 6f3914
  .. method:: enable_source_repos()
Packit 6f3914
Packit 6f3914
    Enable source repos corresponding to already enabled binary repos.
Packit 6f3914
Packit 6f3914
  .. method:: get_matching(key)
Packit 6f3914
Packit 6f3914
    Return a list of repositories which ID matches (possibly globbed) `key` or an empty list if no matching repository is found.
Packit 6f3914
Packit 6f3914
    The returned list acts as a `composite <http://en.wikipedia.org/wiki/Composite_pattern>`_, transparently forwarding all method calls on itself to the contained repositories. The following thus disables all matching repos::
Packit 6f3914
Packit 6f3914
        #!/usr/bin/python3
Packit 6f3914
        import dnf
Packit 6f3914
Packit 6f3914
        base = dnf.Base()
Packit 6f3914
        base.read_all_repos()
Packit 6f3914
        base.fill_sack()
Packit 6f3914
Packit 6f3914
        repos = base.repos.get_matching('*-debuginfo')
Packit 6f3914
        repos.disable()
Packit 6f3914
Packit 6f3914
  .. method:: iter_enabled()
Packit 6f3914
Packit 6f3914
    Return an iterator over all enabled repos from the dict.
Packit 6f3914
Packit 6f3914
.. module:: dnf.repo
Packit 6f3914
Packit 6f3914
.. function:: repo_id_invalid(repo_id)
Packit 6f3914
Packit 6f3914
  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.
Packit 6f3914
Packit 6f3914
.. class:: Metadata
Packit 6f3914
Packit 6f3914
  Represents the metadata files.
Packit 6f3914
Packit 6f3914
  .. attribute:: fresh
Packit 6f3914
Packit 6f3914
    Boolean. ``True`` if the metadata was loaded from the origin, ``False`` if it was loaded from the cache.
Packit 6f3914
Packit 6f3914
.. class:: Repo
Packit 6f3914
Packit 6f3914
  Repository object used for metadata download. To configure it properly one has to give it either :attr:`metalink`, :attr:`mirrorlist` or :attr:`baseurl` parameter.
Packit 6f3914
  This object has attributes corresponding to all configuration options from both :ref:`"Repo Options" <conf_repo_options-label>` and :ref:`"Options for both [main] and Repo" <conf_main_and_repo_options-label>` sections.
Packit 6f3914
Packit 6f3914
  .. IMPORTANT::
Packit 6f3914
    Some :class:`.Repo` attributes have non-native Python types.
Packit 6f3914
    Duck typing works (objects have identical behavior), but ``isinstance()``
Packit 6f3914
    and ``type()`` doesn't work as expected because of different types.
Packit 6f3914
    For example :ref:`excludepkgs <exclude-label>` and :ref:`includepkgs <include-label>` return a ``VectorString``, which
Packit 6f3914
    is s SWIG wrapper on top of underlying libdnf C++ code.
Packit 6f3914
Packit 6f3914
  .. attribute:: id
Packit 6f3914
Packit 6f3914
    ID of this repo. This attribute is read-only.
Packit 6f3914
Packit 6f3914
  .. attribute:: metadata
Packit 6f3914
Packit 6f3914
    If :meth:`~load` has been called and succeeded, this contains the relevant :class:`Metadata` instance.
Packit 6f3914
Packit 6f3914
  .. attribute:: pkgdir
Packit 6f3914
Packit 6f3914
    Directory where packages of a remote repo will be downloaded to. By default it is derived from `cachedir` in :meth:`.__init__` but can be overridden by assigning to this attribute.
Packit 6f3914
Packit 6f3914
  .. attribute:: repofile
Packit 6f3914
Packit 6f3914
    The path to configuration file of the class.
Packit 6f3914
Packit 6f3914
  .. method:: __init__(name=None, parent_conf=None)
Packit 6f3914
Packit 6f3914
    Init repository with ID `name` and the `parent_conf` which an instance of :class:`dnf.conf.Conf`
Packit 6f3914
    holding main dnf configuration. Repository ID must be a string that can contain ASCII letters, digits, and `-_.:` characters.
Packit 6f3914
Packit 6f3914
  .. method:: add_metadata_type_to_download(metadata_type)
Packit 6f3914
Packit 6f3914
    Ask for additional repository metadata type to download. Given `metadata_type` is appended to the default metadata set when repository is downloaded.
Packit 6f3914
Packit 6f3914
  .. method:: disable()
Packit 6f3914
Packit 6f3914
    Disable the repository. Repositories are enabled by default.
Packit 6f3914
Packit 6f3914
  .. method:: dump()
Packit 6f3914
Packit 6f3914
    Print repository configuration, including inherited values.
Packit 6f3914
Packit 6f3914
  .. method:: enable()
Packit 6f3914
Packit 6f3914
    Enable the repository (the default).
Packit 6f3914
Packit 6f3914
  .. method:: get_http_headers()
Packit 6f3914
Packit 6f3914
    Return user defined http headers. Return tuple of strings.
Packit 6f3914
Packit 6f3914
  .. method:: get_metadata_content(metadata_type)
Packit 6f3914
Packit 6f3914
    Return contents of the repository's metadata file of the given metadata type. Contents of compressed files are returned uncompressed.
Packit 6f3914
Packit 6f3914
  .. method:: get_metadata_path(metadata_type)
Packit 6f3914
Packit 6f3914
    Return path to the file with downloaded repository metadata of given type.
Packit 6f3914
Packit 6f3914
  .. method:: load()
Packit 6f3914
Packit 6f3914
    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 :exc:`dnf.exceptions.RepoError` if the repo metadata could not be obtained.
Packit 6f3914
Packit 6f3914
  .. method:: set_http_headers(headers)
Packit 6f3914
Packit 6f3914
    Set new user headers and rewrite existing ones. `headers` must be an instance of tuple of strings or list of strings.
Packit 6f3914
Packit 6f3914
  .. method:: set_progress_bar(progress)
Packit 6f3914
Packit 6f3914
    Set the download progress reporting object for this repo during :meth:`load`. `progress` must be an instance of :class:`dnf.callback.DownloadProgress`.