composeinfo – Compose metadata
This module provides classes for manipulating composeinfo.json files. composeinfo.json files provide details about composes which includes product information, variants, architectures and paths.
Example:
import productmd.compose
compose = productmd.compose.Compose("/path/to/compose")
print(compose.info.compose.id) # prints "Fedora-Rawhide-20180616.n.0"
Constants
- productmd.composeinfo.COMPOSE_TYPES = ['test', 'ci', 'nightly', 'production', 'development']
supported compose types
- productmd.composeinfo.LABEL_NAMES = ['EA', 'DevelPhaseExit', 'InternalAlpha', 'Alpha', 'InternalSnapshot', 'Beta', 'Snapshot', 'RC', 'Update', 'SecurityFix']
supported milestone label names
- productmd.composeinfo.VARIANT_TYPES = ['variant', 'optional', 'addon', 'layered-product']
supported variant types
Classes
- class productmd.composeinfo.ComposeInfo
This class only encapsulates other classes with actual data.
- base_product
(
BaseProduct) – Base product details (optional)
- serialize(parser, force_version=None)
Serialize compose info metadata.
- Parameters:
parser (dict) – Dictionary to serialize into
force_version (tuple or None) – Force output version (overrides output_version)
- 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
- class productmd.composeinfo.Compose(metadata)
This class represents the top level of metadata for a compose.
It provides access to general information about the compose (ID, type, date, etc.) and structures with RPMs and images.
- property label_major_version
Return major version for a label.
Examples: Beta-1.2 -> Beta-1, GA -> GA
- class productmd.composeinfo.Release(metadata)
This class represents a product release.
- name
(str) – Release name, for example: “Fedora”, “Red Hat Enterprise Linux”
- version
(str) – Release version (incl. minor version), for example: “20”, “7.0”
- short
(str) – Release short name, for example: “f”, “rhel”
- type
(str) – Release type, for example: “ga”, “updates”
- is_layered
(bool=False) – Determines if release is a layered product
- internal
(bool=False) – Determine if release is meant for public consumption
- class productmd.composeinfo.BaseProduct(metadata)
This class represents a base product a release is based on. For example: Spacewalk 2.2 release requires Fedora 20 base product. Information from this class is used only if release.is_layered is set.
- name
(str) – Product name, for example: “Fedora”, “Red Hat Enterprise Linux”
- version
(str) – Product version (typically major version), for example: “20”, “7”
- short
(str) – Product short name, for example: “f”, “rhel”
- type
(str) – Product type, for example: “ga”, “eus”
- property type_suffix
This is used in compose ID.
- class productmd.composeinfo.Variants(metadata)
This class is a container for compose variants.
- class productmd.composeinfo.Variant(metadata)
- id
(str) – variant ID, for example: “Client”, “Server”, “optional”
- uid
(str) – variant unique ID: $PARENT_UID-$ID, for example: “Server-optional”
- name
(str) – variant name (pretty text), for example: “Enterprise Server”
- type
(str) – variant type, see VARIANT_TYPES for supported values
- arches
(set(<str>)) – set of arches for a variant
- variants
(dict) – child variants
- paths
(
VariantPaths) – path mappings for a variant
- class productmd.composeinfo.VariantPaths(variant)
This class stores relative paths for a variant in a compose. Paths are represented as dictionaries mapping arches to actual paths. List of supported paths follows.
Binary
os_tree – installable tree with binary RPMs, kickstart trees, readme etc.
packages – directory with binary RPMs
repository – YUM repository with binary RPMs
isos – Binary ISOs
images – Non-ISO Images
jigdos – Jigdo files for binary ISOs
Source
source_tree – tree with source RPMs
source_packages – directory with source RPMs
source_repository – YUM repository with source RPMs
source_isos – Source ISOs
source_jigdos – Jigdo files for source ISOs
Debug
debug_tree – tree with debug RPMs
debug_packages – directory with debug RPMs
debug_repository – YUM repository with debug RPMs
Example:
self.os_tree = { "i386": "Server/i386/os", "x86_64": "Server/x86_64/os", } self.packages = { "i386": "Server/i386/os/Packages", "x86_64": "Server/x86_64/os/Packages", }
- set_location(field_name, arch, location)
Set a Location for a path field, updating both the path string and the internal Location storage.
- Parameters:
field_name (str) – Path field name (e.g.,
"repository","os_tree")arch (str) – Architecture key (e.g.,
"x86_64","src")location (
productmd.location.Location) – Location object
- Raises:
ValueError – if
field_nameis not a known path fieldTypeError – if
locationis not a Location instance
- get_location(field_name, arch)
Get the Location object for a path field, or None.
- Parameters:
field_name (str) – Path field name (e.g.,
"repository","os_tree")arch (str) – Architecture key (e.g.,
"x86_64","src")
- Returns:
Location object or None
- Return type:
productmd.location.Locationor None
Private Classes
- class productmd.composeinfo.VariantBase(metadata)
- __init__(metadata)
- __repr__()
Return repr(self).
- get_variants(arch=None, types=None, recursive=False)
Return all variants of given arch and types.
- Supported variant types:
self - include the top-level (“self”) variant as well addon variant optional