ComplianceAsCode/content

View on GitHub
shared/templates/platform_package/template.py

Summary

Maintainability
A
0 mins
Test Coverage
import re


def preprocess(data, lang):
    pattern = r"^\d+:\d+(?:\.\d+(?:\.\d+)?)?$"
    for ver_spec in data["ver_specs"]:
        version = ver_spec["ev_ver"]
        if not re.match(pattern, version):
            msg = (
                "Error in platform package[%s]: version '%s' doesn't match "
                "pattern '%s'" % (data["pkgname"], version, pattern))
            raise ValueError(msg)
    return data