modules – Module metadata

Classes

class productmd.modules.Modules
serialize(parser, force_version=None)

Serialize module metadata.

Parameters:
  • parser (dict) – Dictionary to serialize into

  • force_version (tuple or None) – Force output version (overrides output_version)

add(variant, arch, uid, koji_tag='', modulemd_path=None, category='binary', rpms=None, location=None)

Map a module to a variant and arch.

Parameters:
  • variant (str) – Variant UID

  • arch (str) – Architecture

  • uid (str) – Module NSVC identifier (name:stream[:version[:context]]). In v2.0 serialized format, the key becomes NSVCA (arch appended).

  • koji_tag (str) – Koji build tag (required for v1.x, optional for v2.0)

  • modulemd_path (str or None) – Relative path to the modulemd YAML file

  • category (str) – Module category (binary, debug, source)

  • rpms (list or tuple) – List of RPM NEVRAs belonging to this module

  • location (Location or None) – Location object for v2.0 distributed composes. When provided, the Location is stored alongside v1.x fields and used during v2.0 serialization. If modulemd_path is not explicitly set, it defaults to location.local_path.

detect_data_version(data: Dict[str, Any]) Tuple[int, int]

Detect version from parsed data.

Parameters:

data (dict) – Parsed metadata

Returns:

Version tuple

Return type:

tuple

dump(f)

Dump data to a file.

Parameters:

f (file or str) – file-like object or path to file

dumps()

Dump data to a string.

Return type:

str

get_output_version(force_version: Tuple[int, int] | None = None) Tuple[int, int]

Resolve the effective output version.

Priority: force_version > output_version (instance) > _default_output_version (class)

Parameters:

force_version (tuple or None) – Explicit version override

Returns:

Version tuple

Return type:

tuple

load(f)

Load data from a file.

Parameters:

f (file or str) – file-like object or path to file

loads(s)

Load data from a string.

Parameters:

s (str) – input data

property output_version: Tuple[int, int]

Get the version to use when serializing.

Returns the instance override if set, otherwise the class default.

Returns:

Version tuple (major, minor)

Return type:

tuple

should_use_locations() bool

Check if Location objects should be used for output.

Returns:

True if using v2.0+ format

Return type:

bool

validate()

Validate attributes by running all self._validate_*() methods.

Raises:
  • TypeError – if an attribute has invalid type

  • ValueError – if an attribute contains invalid value