add build_no and release_tag placeholders

This commit is contained in:
Manuel Barkhau 2018-12-22 00:15:01 +01:00
parent b835a5912f
commit fe019fa546
3 changed files with 46 additions and 32 deletions

View file

@ -41,7 +41,9 @@ RE_PATTERN_PARTS = {
'version' : r"v\d{6}\.\d{4,}(\-(alpha|beta|dev|rc|post))?", 'version' : r"v\d{6}\.\d{4,}(\-(alpha|beta|dev|rc|post))?",
'calver' : r"v\d{6}", 'calver' : r"v\d{6}",
'build' : r"\.\d{4,}", 'build' : r"\.\d{4,}",
'build_no' : r"\d{4,}",
'release' : r"(\-(alpha|beta|dev|rc|post))?", 'release' : r"(\-(alpha|beta|dev|rc|post))?",
'release_tag' : r"(alpha|beta|dev|rc|post)?",
} }

View file

@ -12,7 +12,9 @@
... "year" : "2017", ... "year" : "2017",
... "month" : "12", ... "month" : "12",
... "build" : ".0123", ... "build" : ".0123",
... "build_no" : "0123",
... "release" : "-alpha", ... "release" : "-alpha",
... "release_tag" : "alpha",
... } ... }
>>> >>>
>>> version_info = PYCALVER_RE.match("v201712.0033").groupdict() >>> version_info = PYCALVER_RE.match("v201712.0033").groupdict()
@ -22,7 +24,9 @@
... "year" : "2017", ... "year" : "2017",
... "month" : "12", ... "month" : "12",
... "build" : ".0033", ... "build" : ".0033",
... "build_no" : "0033",
... "release" : None, ... "release" : None,
... "release_tag": None,
... } ... }
""" """
@ -48,11 +52,11 @@ PYCALVER_PATTERN = r"""
) )
(?P<build> (?P<build>
\. # "." build nr prefix \. # "." build nr prefix
\d{4,} (?P<build_no>\d{4,})
) )
(?P<release> (?P<release>
\- # "-" release prefix \- # "-" release prefix
(?:alpha|beta|dev|rc|post) (?P<release_tag>alpha|beta|dev|rc|post)
)? )?
)(?:\s|$) )(?:\s|$)
""" """
@ -69,7 +73,9 @@ class VersionInfo(typ.NamedTuple):
year : str year : str
month : str month : str
build : str build : str
build_no : str
release : typ.Optional[str] release : typ.Optional[str]
release_tag : typ.Optional[str]
def parse_version_info(version_str: str) -> VersionInfo: def parse_version_info(version_str: str) -> VersionInfo:
@ -83,7 +89,9 @@ def parse_version_info(version_str: str) -> VersionInfo:
... year ="2017", ... year ="2017",
... month ="12", ... month ="12",
... build =".0033", ... build =".0033",
... build_no ="0033",
... release ="-beta", ... release ="-beta",
... release_tag ="beta",
... ) ... )
""" """
match = PYCALVER_RE.match(version_str) match = PYCALVER_RE.match(version_str)

View file

@ -88,7 +88,9 @@ def test_readme_pycalver1():
'year' : "2017", 'year' : "2017",
'month' : "12", 'month' : "12",
'build' : ".0001", 'build' : ".0001",
'build_no' : "0001",
'release' : "-alpha", 'release' : "-alpha",
'release_tag': "alpha",
} }
@ -102,7 +104,9 @@ def test_readme_pycalver2():
'year' : "2017", 'year' : "2017",
'month' : "12", 'month' : "12",
'build' : ".0033", 'build' : ".0033",
'build_no' : "0033",
'release' : None, 'release' : None,
'release_tag': None,
} }