py27 compat fix

This commit is contained in:
Manuel Barkhau 2022-10-14 17:10:37 +00:00 committed by mbarkhau
parent afe82cf7c3
commit ae07728a5b

View file

@ -31,6 +31,7 @@
import re import re
import typing as typ import typing as typ
import collections
from . import utils from . import utils
from .patterns import RE_PATTERN_ESCAPES from .patterns import RE_PATTERN_ESCAPES
@ -52,41 +53,43 @@ from .patterns import Pattern
# bad: (?:[1-2][0-9]|3[0-1]|[1-9]) # bad: (?:[1-2][0-9]|3[0-1]|[1-9])
PART_PATTERNS = { PART_PATTERNS = collections.OrderedDict(
# Based on calver.org [
'YYYY': r"[1-9][0-9]{3}", # Based on calver.org
'YY' : r"[1-9][0-9]?", ('YYYY', r"[1-9][0-9]{3}"),
'0Y' : r"[0-9]{2}", ('YY' , r"[1-9][0-9]?"),
'GGGG': r"[1-9][0-9]{3}", ('0Y' , r"[0-9]{2}"),
'GG' : r"[1-9][0-9]?", ('GGGG', r"[1-9][0-9]{3}"),
'0G' : r"[0-9]{2}", ('GG' , r"[1-9][0-9]?"),
'Q' : r"[1-4]", ('0G' , r"[0-9]{2}"),
'MM' : r"1[0-2]|[1-9]", ('Q' , r"[1-4]"),
'0M' : r"1[0-2]|0[1-9]", ('MM' , r"1[0-2]|[1-9]"),
'DD' : r"3[0-1]|[1-2][0-9]|[1-9]", ('0M' , r"1[0-2]|0[1-9]"),
'0D' : r"3[0-1]|[1-2][0-9]|0[1-9]", ('DD' , r"3[0-1]|[1-2][0-9]|[1-9]"),
'JJJ' : r"36[0-6]|3[0-5][0-9]|[1-2][0-9][0-9]|[1-9][0-9]|[1-9]", ('0D' , r"3[0-1]|[1-2][0-9]|0[1-9]"),
'00J' : r"36[0-6]|3[0-5][0-9]|[1-2][0-9][0-9]|0[1-9][0-9]|00[1-9]", ('JJJ' , r"36[0-6]|3[0-5][0-9]|[1-2][0-9][0-9]|[1-9][0-9]|[1-9]"),
# week numbering parts ('00J' , r"36[0-6]|3[0-5][0-9]|[1-2][0-9][0-9]|0[1-9][0-9]|00[1-9]"),
'WW': r"5[0-2]|[1-4][0-9]|[0-9]", # week numbering parts
'0W': r"5[0-2]|[0-4][0-9]", ('WW', r"5[0-2]|[1-4][0-9]|[0-9]"),
'UU': r"5[0-2]|[1-4][0-9]|[0-9]", ('0W', r"5[0-2]|[0-4][0-9]"),
'0U': r"5[0-2]|[0-4][0-9]", ('UU', r"5[0-2]|[1-4][0-9]|[0-9]"),
'VV': r"5[0-3]|[1-4][0-9]|[1-9]", ('0U', r"5[0-2]|[0-4][0-9]"),
'0V': r"5[0-3]|[1-4][0-9]|0[1-9]", ('VV', r"5[0-3]|[1-4][0-9]|[1-9]"),
# non calver parts ('0V', r"5[0-3]|[1-4][0-9]|0[1-9]"),
'MAJOR' : r"[0-9]+", # non calver parts
'MINOR' : r"[0-9]+", ('MAJOR' , r"[0-9]+"),
'PATCH' : r"[0-9]+", ('MINOR' , r"[0-9]+"),
'BUILD' : r"[0-9]+", ('PATCH' , r"[0-9]+"),
'BLD' : r"[1-9][0-9]*", ('BUILD' , r"[0-9]+"),
'TAG' : r"preview|final|alpha|beta|post|rc", ('BLD' , r"[1-9][0-9]*"),
'PYTAG' : r"post|rc|a|b", ('TAG' , r"preview|final|alpha|beta|post|rc"),
'GITHASH': r"\.[0-9]+\+.*", ('PYTAG' , r"post|rc|a|b"),
'NUM' : r"[0-9]+", ('GITHASH', r"\.[0-9]+\+.*"),
'INC0' : r"[0-9]+", ('NUM' , r"[0-9]+"),
'INC1' : r"[1-9][0-9]*", ('INC0' , r"[0-9]+"),
} ('INC1' , r"[1-9][0-9]*"),
]
)
PATTERN_PART_FIELDS = { PATTERN_PART_FIELDS = {