-
Notifications
You must be signed in to change notification settings - Fork 172
/
_version.py
60 lines (50 loc) · 1.55 KB
/
_version.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""Version information for pynetdicom based on PEP396 and 440"""
import re
# pynetdicom version
__version__ = "2.1.0"
# DICOM Standard version used for SOP classes and instances
__dicom_version__: str = "2024b"
VERSION_PATTERN = r"""
v?
(?:
(?:(?P<epoch>[0-9]+)!)? # epoch
(?P<release>[0-9]+(?:\.[0-9]+)*) # release segment
(?P<pre> # pre-release
[-_\.]?
(?P<pre_l>(a|b|c|rc|alpha|beta|pre|preview))
[-_\.]?
(?P<pre_n>[0-9]+)?
)?
(?P<post> # post release
(?:-(?P<post_n1>[0-9]+))
|
(?:
[-_\.]?
(?P<post_l>post|rev|r)
[-_\.]?
(?P<post_n2>[0-9]+)?
)
)?
(?P<dev> # dev release
[-_\.]?
(?P<dev_l>dev)
[-_\.]?
(?P<dev_n>[0-9]+)?
)?
)
(?:\+(?P<local>[a-z0-9]+(?:[-_\.][a-z0-9]+)*))? # local version
"""
def is_canonical(version: str) -> bool:
"""Return True if `version` is a PEP440 conformant version."""
match = re.match(
(
r"^([1-9]\d*!)?(0|[1-9]\d*)"
r"(\.(0|[1-9]\d*))"
r"*((a|b|rc)(0|[1-9]\d*))"
r"?(\.post(0|[1-9]\d*))"
r"?(\.dev(0|[1-9]\d*))?$"
),
version,
)
return match is not None
assert is_canonical(__version__)