Blame doc/api_module.rst

Packit 6f3914
..
Packit 6f3914
  Copyright (C) 2019 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
 Modularity Interface
Packit 6f3914
=====================
Packit 6f3914
Packit 6f3914
.. module:: dnf.module.module_base
Packit 6f3914
Packit 6f3914
Packit 6f3914
.. class:: dnf.module.module_base.ModuleBase
Packit 6f3914
Packit 6f3914
Basic class for handling modules.
Packit 6f3914
Packit 6f3914
  .. method:: __init__(base)
Packit 6f3914
Packit 6f3914
    Initialize :class:`dnf.module.module_base.ModuleBase` object. `base` is an instance of the :class:`dnf.Base` class.
Packit 6f3914
Packit 6f3914
  .. method:: enable(module_specs)
Packit 6f3914
Packit 6f3914
    Mark module streams matching the `module_specs` list and also all required modular dependencies for enabling.
Packit 6f3914
    For specs that do not specify the stream, the default stream is used. In case that the module has only one stream available, this stream is used regardles of whether it is the default or not.
Packit 6f3914
    Note that only one stream of any given module can be enabled on a system.
Packit 6f3914
    The method raises :exc:`dnf.exceptions.MarkingErrors` in case of errors.
Packit 6f3914
Packit 6f3914
    Example::
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
        module_base = dnf.module.module_base.ModuleBase(base)
Packit 6f3914
        module_base.enable(['nodejs:11'])
Packit 6f3914
Packit 6f3914
        base.do_transaction()
Packit 6f3914
Packit 6f3914
  .. method:: disable(module_specs)
Packit 6f3914
Packit 6f3914
    Mark modules matching the `module_specs` list for disabling. Only the name part of the module specification is relevant. Stream, version, context, arch and profile parts are ignored (if given). All streams of the module will be disabled and all installed profiles will be removed. Packages previously installed from these modules will remain installed on the system.
Packit 6f3914
    The method raises :exc:`dnf.exceptions.MarkingErrors` in case of errors.
Packit 6f3914
Packit 6f3914
    Example::
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
        module_base = dnf.module.module_base.ModuleBase(base)
Packit 6f3914
        module_base.disable(['nodejs'])
Packit 6f3914
Packit 6f3914
        base.do_transaction()
Packit 6f3914
Packit 6f3914
  .. method:: reset(module_specs)
Packit 6f3914
Packit 6f3914
    Mark module for resetting so that it will no longer be enabled or disabled. All installed profiles of streams that have been reset will be removed.
Packit 6f3914
    The method raises :exc:`dnf.exceptions.MarkingErrors` in case of errors.
Packit 6f3914
Packit 6f3914
  .. method:: install(module_specs, strict=True)
Packit 6f3914
Packit 6f3914
    Mark module profiles matching `module_specs` for installation and enable all required streams. If the stream or profile part of specification is not specified, the defaults are chosen. All packages of installed profiles are also marked for installation.
Packit 6f3914
    If `strict` is set to ``False``, the installation skips modules with dependency solving problems.
Packit 6f3914
    The method raises :exc:`dnf.exceptions.MarkingErrors` in case of errors.
Packit 6f3914
Packit 6f3914
    Example::
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
        module_base = dnf.module.module_base.ModuleBase(base)
Packit 6f3914
        module_base.install(['nodejs:11/minimal'])
Packit 6f3914
Packit 6f3914
        base.resolve()
Packit 6f3914
        base.download_packages(base.transaction.install_set)
Packit 6f3914
        base.do_transaction()
Packit 6f3914
Packit 6f3914
  .. method:: remove(module_specs)
Packit 6f3914
Packit 6f3914
    Mark module profiles matching `module_spec` for removal. All packages installed from removed profiles (unless they are required by other profiles or user-installed packages) are also marked for removal.
Packit 6f3914
Packit 6f3914
  .. method:: upgrade(module_specs)
Packit 6f3914
Packit 6f3914
    Mark packages of module streams (or profiles) matching `module_spec` for upgrade.
Packit 6f3914
Packit 6f3914
  .. method:: get_modules(module_spec)
Packit 6f3914
Packit 6f3914
    Get information about modules matching `module_spec`. Returns tuple (module_packages, nsvcap), where `nsvcap` is a hawkey.NSVCAP object parsed from `module_spec` and `module_packages` is a tuple of :class:`libdnf.module.ModulePackage` objects matching this `nsvcap`.
Packit 6f3914
Packit 6f3914
    Example::
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
        module_base = dnf.module.module_base.ModuleBase(base)
Packit 6f3914
        module_packages, nsvcap = module_base.get_modules('nodejs:11/minimal')
Packit 6f3914
Packit 6f3914
        print("Parsed NSVCAP:")
Packit 6f3914
        print("name:", nsvcap.name)
Packit 6f3914
        print("stream:", nsvcap.stream)
Packit 6f3914
        print("version:", nsvcap.version)
Packit 6f3914
        print("context:", nsvcap.context)
Packit 6f3914
        print("arch:", nsvcap.arch)
Packit 6f3914
        print("profile:", nsvcap.profile)
Packit 6f3914
Packit 6f3914
        print("Matching modules:")
Packit 6f3914
        for mpkg in module_packages:
Packit 6f3914
            print(mpkg.getFullIdentifier())
Packit 6f3914
Packit 6f3914
Packit 6f3914
Packit 6f3914
Packit 6f3914
.. class:: libdnf.module.ModulePackage
Packit 6f3914
Packit 6f3914
This class represents a record identified by NSVCA from the repository modular metadata. See also https://github.com/fedora-modularity/libmodulemd/blob/master/spec.v2.yaml.
Packit 6f3914
Packit 6f3914
  .. method:: getName()
Packit 6f3914
Packit 6f3914
    Return the name of the module.
Packit 6f3914
Packit 6f3914
  .. method:: getStream()
Packit 6f3914
Packit 6f3914
    Return the stream of the module.
Packit 6f3914
Packit 6f3914
  .. method:: getVersion()
Packit 6f3914
Packit 6f3914
    Return the version of the module as a string.
Packit 6f3914
Packit 6f3914
  .. method:: getVersionNum()
Packit 6f3914
Packit 6f3914
    Return the version of the module as a number.
Packit 6f3914
Packit 6f3914
  .. method:: getContext()
Packit 6f3914
Packit 6f3914
    Return the context of the module.
Packit 6f3914
Packit 6f3914
  .. method:: getArch()
Packit 6f3914
Packit 6f3914
    Return the architecture of the module.
Packit 6f3914
Packit 6f3914
  .. method:: getNameStream()
Packit 6f3914
Packit 6f3914
    Return string in the form of 'name:stream' for the module.
Packit 6f3914
Packit 6f3914
  .. method:: getNameStreamVersion()
Packit 6f3914
Packit 6f3914
    Return string in the form of 'name:stream:version' for the module.
Packit 6f3914
Packit 6f3914
  .. method:: getFullIdentifier()
Packit 6f3914
Packit 6f3914
    Return string in the form of 'name:stream:version:context:architecture' for the module.
Packit 6f3914
Packit 6f3914
  .. method:: getProfiles(name=None)
Packit 6f3914
Packit 6f3914
    Return tuple of :class:`libdnf.module.ModuleProfile` instancies representing each of the individual profiles of the module. If the `name` is given, only profiles matching the `name` pattern are returned.
Packit 6f3914
Packit 6f3914
  .. method:: getSummary()
Packit 6f3914
Packit 6f3914
    Return the summary of the module.
Packit 6f3914
Packit 6f3914
  .. method:: getDescription()
Packit 6f3914
Packit 6f3914
    Return the description of the module.
Packit 6f3914
Packit 6f3914
  .. method:: getRepoID()
Packit 6f3914
Packit 6f3914
    Return the identifier of source repository of the module.
Packit 6f3914
Packit 6f3914
  .. method:: getArtifacts()
Packit 6f3914
Packit 6f3914
    Return tuple of the artifacts of the module.
Packit 6f3914
Packit 6f3914
  .. method:: getModuleDependencies()
Packit 6f3914
Packit 6f3914
    Return tuple of :class:`libdnf.module.ModuleDependencies` objects representing modular dependencies of the module.
Packit 6f3914
Packit 6f3914
  .. method:: getYaml()
Packit 6f3914
Packit 6f3914
    Return repomd yaml representing the module.
Packit 6f3914
Packit 6f3914
Packit 6f3914
Packit 6f3914
.. class:: libdnf.module.ModuleProfile
Packit 6f3914
Packit 6f3914
  .. method:: getName()
Packit 6f3914
Packit 6f3914
    Return the name of the profile.
Packit 6f3914
Packit 6f3914
  .. method:: getDescription()
Packit 6f3914
Packit 6f3914
    Return the description of the profile.
Packit 6f3914
Packit 6f3914
  .. method:: getContent()
Packit 6f3914
Packit 6f3914
    Return tuple of package names to be installed with this profile.
Packit 6f3914
Packit 6f3914
Packit 6f3914
Packit 6f3914
.. class:: libdnf.module.ModuleDependencies
Packit 6f3914
Packit 6f3914
  .. method:: getRequires()
Packit 6f3914
Packit 6f3914
    Return tuple of MapStringVectorString objects. These objects behave like standard python dictionaries and represent individual dependencies of the given module. Keys are names of required modules, values are tuples of required streams specifications.
Packit 6f3914
Packit 6f3914
Packit 6f3914
Packit 6f3914
.. class:: libdnf.module.ModulePackageContainer
Packit 6f3914
Packit 6f3914
    This class is under development and should be considered unstable at the moment.
Packit 6f3914