in elastic_transport/client_utils.py [0:0]
def client_meta_version(version: str) -> str:
"""Converts a Python version into a version string
compatible with the ``X-Elastic-Client-Meta`` HTTP header.
"""
match = re.match(r"^([0-9][0-9.]*[0-9]|[0-9])(.*)$", version)
if match is None:
raise ValueError(
"Version {version!r} not formatted like a Python version string"
)
version, version_suffix = match.groups()
# Don't treat post-releases as pre-releases.
if re.search(r"^\.post[0-9]*$", version_suffix):
return version
if version_suffix:
version += "p"
return version