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