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.
| PARAMETER | DESCRIPTION |
|---|---|
version_string
|
Version string to parse
TYPE:
|
parse_pattern
|
The regular expression pattern to use for parsing
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
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 | DESCRIPTION |
|---|---|
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
| PARAMETER | DESCRIPTION |
|---|---|
version
|
The version to serialize
TYPE:
|
serialize_patterns
|
The serialization format to use, using Python’s format string syntax |
context
|
The context to use when serializing the version
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The serialized version as a string |
| RAISES | DESCRIPTION |
|---|---|
FormattingError
|
if a serialization pattern |