paperwork: Migrate to newer semver construction methods
This commit is contained in:
parent
a7544e4c61
commit
7d84e38e1b
@ -1,6 +1,6 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
import semver
|
from semver import VersionInfo
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.core.validators import RegexValidator
|
from django.core.validators import RegexValidator
|
||||||
|
|
||||||
@ -118,17 +118,15 @@ class CertificationVersion(models.Model):
|
|||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
def semantic_version(self) -> semver.VersionInfo:
|
def semantic_version(self) -> VersionInfo:
|
||||||
if self.version is None:
|
if self.version is None:
|
||||||
return "0.0.0-none"
|
return "0.0.0-none"
|
||||||
elif self.version == "MembershipWorks Label":
|
elif self.version == "MembershipWorks Label":
|
||||||
return semver.parse_version_info("0.0.1-mw-label")
|
return VersionInfo.parse("0.0.1-mw-label")
|
||||||
elif match := VALID_SEMVER_PATTERN.match(self.version):
|
elif match := VALID_SEMVER_PATTERN.match(self.version):
|
||||||
return semver.parse_version_info(
|
return VersionInfo.parse(f'{match["semver"]}+{match["approvaldate"]}')
|
||||||
f'{match["semver"]}+{match["approvaldate"]}'
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
return semver.parse_version_info(
|
return VersionInfo.parse(
|
||||||
"0.0.1-" + re.sub(r"[^.a-zA-Z0-9]", "-", self.version)
|
"0.0.1-" + re.sub(r"[^.a-zA-Z0-9]", "-", self.version)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user