common – Base classes and common functions¶
This module provides base classes and common functions used in other productmd modules.
Constants¶
-
productmd.common.
RELEASE_TYPES
= ['fast', 'ga', 'updates', 'eus', 'aus', 'els']¶ Supported release types.
-
productmd.common.
RELEASE_SHORT_RE
= <_sre.SRE_Pattern object>¶ Validation regex for release short name: [a-z] followed by [a-z0-9] separated with dashes.
-
productmd.common.
RELEASE_VERSION_RE
= <_sre.SRE_Pattern object>¶ Validation regex for release version: any string or [0-9] separated with dots.
Functions¶
-
productmd.common.
parse_nvra
(nvra)¶ Parse RPM N-E:V-R.A string to a dict.
Parameters: nvra (str) – N-E:V-R.A string, eventually a file name or a file path incl. ‘.rpm’ suffix Return type: dict
-
productmd.common.
create_release_id
(short, version, type, bp_short=None, bp_version=None, bp_type=None)¶ Create release_id from given parts.
Parameters: - short (str) – Release short name
- version (str) – Release version
- version – Release type
- bp_short (str) – Base Product short name
- bp_version (str) – Base Product version
- bp_version – Base Product type
Return type: str
-
productmd.common.
parse_release_id
(release_id)¶ Parse release_id to parts: {short, version, type} or {short, version, type, bp_short, bp_version, bp_type}
Parameters: release_id (str) – Release ID string Return type: dict
-
productmd.common.
is_valid_release_short
(short)¶ Determine if given release short name is valid.
Parameters: short (str) – Release short name Return type: bool
-
productmd.common.
is_valid_release_version
(version)¶ Determine if given release version is valid.
Parameters: version (str) – Release version Return type: bool
-
productmd.common.
split_version
(version)¶ Split version to a list of integers that can be easily compared.
Parameters: version (str) – Release version Return type: [int] or [string]
-
productmd.common.
get_major_version
(version, remove=1)¶ Return major version of a provided version string.
Parameters: - version (str) – Version string
- remove (int) – Number of version parts to remove; defaults to 1
Return type: str
-
productmd.common.
get_minor_version
(version, remove=1)¶ Return minor version of a provided version string.
Parameters: - version (str) – Version string
- remove (int) – Number of version parts to remove; defaults to 1
Return type: str
Classes¶
-
class
productmd.common.
MetadataBase
¶ -
validate
()¶ Validate attributes by running all self._validate_*() methods.
Raises: - TypeError – if an attribute has invalid type
- ValueError – if an attribute contains invalid value
-
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
-
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
-
-
class
productmd.common.
Header
(parent, metadata_type)¶ This class represents the header used in serialized metadata files.
It consists of a type and a version. The type is meant purely for consumers of the file to know what they are dealing with without having to check filename. The version is used by productmd when parsing the file.