Modulemd.ModuleIndex

g GObject.Object GObject.Object Modulemd.ModuleIndex Modulemd.ModuleIndex GObject.Object->Modulemd.ModuleIndex

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

add_defaults (defaults)

add_module_stream (stream)

add_obsoletes (obsoletes)

add_translation (translation)

clear_xmds ()

dump_to_string ()

get_default_streams (intent)

get_defaults_mdversion ()

get_module (module_name)

get_module_names ()

get_stream_mdversion ()

remove_module (module_name)

search_rpms (nevra_pattern)

search_streams (module_name, stream_name, version, context, arch)

search_streams_by_nsvca_glob (nsvca_pattern)

update_from_defaults_directory (path, strict, overrides_path)

update_from_file (yaml_file, strict)

update_from_string (yaml_string, strict)

upgrade_defaults (mdversion)

upgrade_streams (mdversion)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class Modulemd.ModuleIndex(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Modulemd.ModuleIndexClass

classmethod new()
Returns:

A newly-allocated Modulemd.ModuleIndex object.

Return type:

Modulemd.ModuleIndex

New in version 2.0.

add_defaults(defaults)
Parameters:

defaults (Modulemd.Defaults) – The Modulemd.Defaults object to add to the index.

Raises:

GLib.Error

Returns:

True if the Modulemd.Defaults was added successfully. If the defaults already existed in the index, it will be replaced by the new one. On failure, returns False and sets error appropriately.

Return type:

bool

New in version 2.0.

add_module_stream(stream)
Parameters:

stream (Modulemd.ModuleStream) – The Modulemd.ModuleStream to add to the index. The stream added must have a module name and stream name set on it or it will be rejected.

Raises:

GLib.Error

Returns:

True if the Modulemd.ModuleStream was added successfully. If the stream already existed in the index, it will be replaced by the new one. On failure, returns False and sets error appropriately.

Return type:

bool

Add a Modulemd.ModuleStream to the Modulemd.ModuleIndex. While being added, the Modulemd.ModuleStream will be upgraded to Modulemd.ModuleStreamVersionEnum.LATEST to ensure that merges done with Modulemd.ModuleIndexMerger will always occur between streams of the same version. If this upgrade cannot be performed, the function will return error set appropriately.

New in version 2.0.

add_obsoletes(obsoletes)
Parameters:

obsoletes (Modulemd.Obsoletes) – The Modulemd.Obsoletes object to add to the index.

Raises:

GLib.Error

Returns:

True if the Modulemd.Obsoletes was added successfully. If the obsoletes already existed in the index, it will be replaced by the new one. On failure, returns False and sets error appropriately.

Return type:

bool

New in version 2.10.

add_translation(translation)
Parameters:

translation (Modulemd.Translation) – The Modulemd.Translation object to add to the index.

Raises:

GLib.Error

Returns:

True if the Modulemd.Translation was added successfully. If the translation already existed in the index, it will be replaced by the new one. On failure, returns False and sets error appropriately.

Return type:

bool

New in version 2.0.

clear_xmds()

Iterates through all Modulemd.ModuleStream entries in this Modulemd.ModuleIndex and removes any XMD sections that are present. This is generally done to trim down the metadata to only the portions that are useful to the package manager.

New in version 2.14.

dump_to_string()
Raises:

GLib.Error

Returns:

A YAML representation of the index as a string. In the event of an error, sets error appropriately and returns None.

Return type:

str

New in version 2.0.

get_default_streams(intent)
Parameters:

intent (str or None) – The name of the system intent whose default stream will be retrieved. If left None or the specified intent has no separate default, it will return the generic default stream for this module.

Returns:

A GLib.HashTable with the module name as the key and the default stream as the value for all modules with a default stream in the index. Modules without a default stream will not appear in this table.

Return type:

{str: str}

Get a dictionary of all modules in the index that have a default stream.

This function cannot fail, but may return an empty (non-None) GLib.HashTable.

New in version 2.5.

get_defaults_mdversion()
Returns:

The metadata version of Modulemd.Defaults in use for this index.

Return type:

Modulemd.DefaultsVersionEnum

New in version 2.0.

get_module(module_name)
Parameters:

module_name (str) – The module name to look up in the index.

Returns:

The Modulemd.Module object matching the provided module name or None if the key was not present in the index.

Return type:

Modulemd.Module

New in version 2.0.

get_module_names()
Returns:

An ordered list of string keys in this index.

Return type:

[str]

New in version 2.0.

get_stream_mdversion()
Returns:

The metadata version of Modulemd.ModuleStream in use for this index.

Return type:

Modulemd.ModuleStreamVersionEnum

New in version 2.0.

remove_module(module_name)
Parameters:

module_name (str) – The name of the module to remove from the index.

Returns:

True if the module name was present in the index. False if it was not.

Return type:

bool

Remove a module, including all of its streams, its defaults and its translations from a Modulemd.ModuleIndex.

New in version 2.2.

search_rpms(nevra_pattern)
Parameters:

nevra_pattern (str) – A glob pattern to match against the NEVRA strings of the rpm artifacts in the Modulemd.ModuleStream objects in this module.

Returns:

The list of stream objects containing an RPM that matches the nevra_pattern. This function cannot fail, but it may return a zero-length list if no matches were found. The returned streams will be in a predictable order, sorted first by module name, then stream name, then by version (highest first), then by context and finally by architecture.

Return type:

[Modulemd.ModuleStream]

All arguments to this method will be compared using fnmatch(3).

New in version 2.9.

search_streams(module_name, stream_name, version, context, arch)
Parameters:
  • module_name (str or None) – The name of the module to retrieve. If None, will search all modules in the index.

  • stream_name (str or None) – The name of the stream to retrieve. If None, will search all streams in a module.

  • version (str or None) – The version of the stream to retrieve. If None, will search all versions.

  • context (str or None) – The context of the stream to retrieve. If None, will search all contexts.

  • arch (str or None) – The processor architecture of the stream to retrieve. If None, the architecture is not included in the search.

Returns:

The list of stream objects matching all of the requested parameters. This function cannot fail, but it may return a zero-length list if no matches were found. The returned streams will be in a predictable order, sorted first by module name, then stream name, then by version (highest first), then by context and finally by architecture.

Return type:

[Modulemd.ModuleStream]

All arguments to this method will be compared using fnmatch(3).

New in version 2.9.

search_streams_by_nsvca_glob(nsvca_pattern)
Parameters:

nsvca_pattern (str or None) – A glob pattern to match against the NSVCA strings of the Modulemd.ModuleStream objects in this module. If None, this will match all NSVCAs.

Returns:

The list of stream objects matching all of the requested parameters. This function cannot fail, but it may return a zero-length list if no matches were found. The returned streams will be in a predictable order, sorted first by module name, then stream name, then by version (highest first), then by context and finally by architecture.

Return type:

[Modulemd.ModuleStream]

New in version 2.9.

update_from_defaults_directory(path, strict, overrides_path)
Parameters:
  • path (str) – The path to a directory containing defaults documents.

  • strict (bool) – Whether the parser should return failure if it encounters an unknown mapping key or a conflict in module default streams.

  • overrides_path (str or None) – If non-None, the path to a directory containing defaults documents that should override those in path.

Raises:

GLib.Error

Returns:

True if all “.yaml” files in the directory were imported successfully (this includes if no “.yaml” files were present). False if one or more files could not be read successfully and sets error appropriately.

Return type:

bool

This function will open the directory at path and iterate through it, adding any files with the suffix “.yaml” to self. If overrides_path is non-None, it will also open any files with the suffix “.yaml” in that location and import them, overriding any conflicts with the existing defaults.

Note: If you need detailed information about what failed and why, it is better to implement the directory traversal yourself and use the Modulemd.ModuleIndex.update_from_file() function, as it will return the failures information.

New in version 2.8.

update_from_file(yaml_file, strict)
Parameters:
  • yaml_file (str) – A name of a YAML file containing the module metadata and other related information such as default streams.

  • strict (bool) – Whether the parser should return failure if it encounters an unknown mapping key or if it should ignore it.

Raises:

GLib.Error

Returns:

True if the update was successful. Returns False and sets failures appropriately if any of the YAML subdocuments were invalid or sets error if there was a fatal parse error.

failures:

On output, an array containing any subdocuments (pointers to Modulemd.SubdocumentInfo) from the YAML file that failed to parse. On input, it must be a non-None pointer. If that pointer points to None, this call will allocate a new array (regardless of any failures) with an element destructor set to GObject.Object.unref(). Otherwise, the pointed array is reused without emptying before adding the failed subdocuments. The caller is responsible for freeing the array.

Return type:

(bool, failures: [Modulemd.SubdocumentInfo])

New in version 2.0.

update_from_string(yaml_string, strict)
Parameters:
  • yaml_string (str) – A YAML string containing the module metadata and other related information such as default streams.

  • strict (bool) – Whether the parser should return failure if it encounters an unknown mapping key or if it should ignore it.

Raises:

GLib.Error

Returns:

True if the update was successful. Returns False and sets failures appropriately if any of the YAML subdocuments were invalid or sets error if there was a fatal parse error.

failures:

On output, an array containing any subdocuments (pointers to Modulemd.SubdocumentInfo) from the YAML file that failed to parse. On input, it must be a non-None pointer. If that pointer points to None, this call will allocate a new array (regardless of any failures) with an element destructor set to GObject.Object.unref(). Otherwise, the pointed array is reused without emptying before adding the failed subdocuments. The caller is responsible for freeing the array.

Return type:

(bool, failures: [Modulemd.SubdocumentInfo])

New in version 2.0.

upgrade_defaults(mdversion)
Parameters:

mdversion (Modulemd.DefaultsVersionEnum) – The Modulemd.Defaults metadata version to upgrade to.

Raises:

GLib.Error

Return type:

bool

Upgrades all Modulemd.Defaults objects in this index to mdversion if they are not already at that version. An attempt to downgrade or an attempt to upgrade beyond the latest supported version will report an error. In the case of a failure to upgrade a particular Modulemd.Defaults object of the index, an error will be reported and the index will be left in an undefined state.

New in version 2.0.

upgrade_streams(mdversion)
Parameters:

mdversion (Modulemd.ModuleStreamVersionEnum) – The Modulemd.ModuleStream metadata version to upgrade to.

Raises:

GLib.Error

Return type:

bool

Upgrades all Modulemd.ModuleStream objects in this index to mdversion if they are not already at that version.

New in version 2.0.