Source code for ska_telmodel.sdp.version

"""SDP schema prefixes and versions."""

from ska_telmodel._common import ALLOW_DEV_VERSION

SDP_ASSIGNRES_PREFIX = "https://schema.skao.int/ska-sdp-assignres/"
SDP_RELEASERES_PREFIX = "https://schema.skao.int/ska-sdp-releaseres/"
SDP_CONFIGURE_PREFIX = "https://schema.skao.int/ska-sdp-configure/"
SDP_SCAN_PREFIX = "https://schema.skao.int/ska-sdp-scan/"
SDP_RECVADDRS_PREFIX = "https://schema.skao.int/ska-sdp-recvaddrs/"

SDP_INTERFACE_STABLE_VERSIONS = [
    (0, 1),
    (0, 2),
    (0, 3),
    (0, 4),
    (0, 5),
    (1, 0),
    (1, 1),
]

SDP_INTERFACE_DEV_VERSIONS = []

SDP_INTERFACE_VERSIONS = (
    SDP_INTERFACE_STABLE_VERSIONS + SDP_INTERFACE_DEV_VERSIONS
    if ALLOW_DEV_VERSION
    else SDP_INTERFACE_STABLE_VERSIONS
)


[docs] def version_strings( version_tuples: list[tuple[int, int]], min_ver=(0, 0), max_ver=(float("inf"), 0), ): """ Filter a list of version between min_ver and max_ver and convert to strings :param version_tuples: List of (MAJOR, MINOR) version tuples :param min_ver: Tuple of minimum version to return :param max_ver: Tuple of maximum version to return """ sdp_vers = filter(lambda v: v >= min_ver and v <= max_ver, version_tuples) return [f"{v0}.{v1}" for v0, v1 in sdp_vers]
[docs] def sdp_interface_versions( prefix: str, min_ver=(0, 0), max_ver=(float("inf"), 0) ): """ Returns a list of SDP interface version URIs :param prefix: Interface URI prefix :param min_ver: Tuple of minimum version to return :param max_ver: Tuple of maximum version to return """ assert ( prefix[-1] == "/" ), "Please only pass prefixes ending with '/' to sdp_interface_versions!" sdp_version_strings = version_strings( SDP_INTERFACE_VERSIONS, min_ver, max_ver ) return [f"{prefix}{v}" for v in sdp_version_strings]