serialization
Functions for serializing and deserializing version objects.
Classes¶
Functions¶
multisort
¶
multisort(xs: list, specs: tuple) -> list
parse_version
¶
parse_version(
version_string: str, parse_pattern: str
) -> Dict[str, str]
Parse a version string into a dictionary of the parts and values using a regular expression.
Parameters:
version_string
-
Version string to parse
TYPE:
str
parse_pattern
-
The regular expression pattern to use for parsing
TYPE:
str
Returns:
-
Dict[str, str]
-
A dictionary of version part labels and their values, or an empty dictionary
-
Dict[str, str]
-
if the version string doesn’t match.
Raises:
-
BumpVersionError
-
If the parse_pattern is not a valid regular expression
serialize
¶
serialize(
version: Version,
serialize_patterns: List[str],
context: MutableMapping,
) -> str
Attempts to serialize a version with the given serialization format.
- valid serialization patterns are those that are renderable with the given context
- formats that contain all required components are preferred
- the shortest valid serialization pattern is used
- if two patterns are equally short, the first one is used
- if no valid serialization pattern is found, an error is raised
Parameters:
version
-
The version to serialize
TYPE:
Version
serialize_patterns
-
The serialization format to use, using Python’s format string syntax
context
-
The context to use when serializing the version
TYPE:
MutableMapping
Raises:
-
FormattingError
-
if a serialization pattern
Returns:
-
str
-
The serialized version as a string