some testing

This commit is contained in:
Manuel Barkhau 2018-09-03 09:19:27 +02:00
parent 02b4ff2899
commit 8189075385
6 changed files with 295 additions and 38 deletions

View file

@ -107,16 +107,9 @@ def main():
print(f"{_curr_id:<13} {ord_val(_curr_id):>12}")
_next_id = next_id(_curr_id)
assert _curr_id < next_id
assert int(_curr_id, 10) < int(next_id, 10)
assert ord_val(_curr_id) < ord_val(next_id)
# while next_id.startswith("0") and int(next_id) < 1000:
# _next_id = next_id(_next_id)
if next_id.count("9") == len(next_id):
if _next_id.count("9") == len(_next_id):
# all nines, we're done
print(f"{next_id:<13} {ord_val(next_id):>12}")
print(f"{_next_id:<13} {ord_val(_next_id):>12}")
break
if _next_id[0] != _curr_id[0] and len(_curr_id) > 1:

View file

@ -5,15 +5,10 @@
# SPDX-License-Identifier: MIT
import re
import io
import os
import sys
import logging
import typing as typ
import datetime as dt
import pkg_resources
from . import lex_id
log = logging.getLogger("pycalver.parse")
@ -42,12 +37,19 @@ PYCALVER_RE: typ.re.Pattern[str] = re.compile(r"""
""", flags=re.VERBOSE)
# NOTE (mb 2018-09-03): These are matchers for parts, which are
# used in the patterns, they're not for validation. This means
# that they may find strings, which are not valid pycalver
# strings, when parsed in their full context. For such cases,
# the patterns should be expanded.
RE_PATTERN_PARTS = {
"pep440_version" : r"\b\d{6}\.[1-9]\d*(a|b|dev|rc|post)?\d*(?:\s|$)",
"version" : r"v\d{6}\.\d{4,}\-(?:alpha|beta|dev|rc|post)",
"pep440_version" : r"\d{6}\.[1-9]\d*(a|b|dev|rc|post)?\d*",
"version" : r"v\d{6}\.\d{4,}(\-(alpha|beta|dev|rc|post))?",
"calver" : r"v\d{6}",
"build" : r"\.\d{4,}",
"release" : r"(\-(?:alpha|beta|dev|rc|post))?",
"release" : r"(\-(alpha|beta|dev|rc|post))?",
}
@ -73,7 +75,7 @@ class VersionInfo(typ.NamedTuple):
def parse_version_info(version: str) -> VersionInfo:
match = PYCALVER_RE.match(version)
pep440_version = pkg_resources.parse_version(version)
pep440_version = str(pkg_resources.parse_version(version))
return VersionInfo(pep440_version=pep440_version, **match.groupdict())