Skip to content

Commit e08c4a5

Browse files
authored
v0.2.2
2 parents 3d6e478 + 2f073e8 commit e08c4a5

File tree

5 files changed

+148
-65
lines changed

5 files changed

+148
-65
lines changed

doc/Dependency.rst

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,21 @@ the mandatory dependencies too.
5454
5555
.. rubric:: Dependency List
5656

57-
+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
58-
| **Package** | **Version** | **License** | **Dependencies** |
59-
+===========================================================+=============+========================================================================================+======================+
60-
| `pytest <https://GitHub.com/pytest-dev/pytest>`__ | ≥7.2.0 | `MIT <https://GitHub.com/pytest-dev/pytest/blob/master/LICENSE>`__ | *Not yet evaluated.* |
61-
+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
62-
| `pytest-cov <https://GitHub.com/pytest-dev/pytest-cov>`__ | ≥4.0.0 | `MIT <https://GitHub.com/pytest-dev/pytest-cov/blob/master/LICENSE>`__ | *Not yet evaluated.* |
63-
+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
64-
| `Coverage <https://GitHub.com/nedbat/coveragepy>`__ | ≥7.0 | `Apache License, 2.0 <https://GitHub.com/nedbat/coveragepy/blob/master/LICENSE.txt>`__ | *Not yet evaluated.* |
65-
+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
66-
| `mypy <https://GitHub.com/python/mypy>`__ | ≥1.2 | `MIT <https://GitHub.com/python/mypy/blob/master/LICENSE>`__ | *Not yet evaluated.* |
67-
+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
68-
| `lxml <https://GitHub.com/lxml/lxml>`__ | ≥4.9 | `BSD 3-Clause <https://GitHub.com/lxml/lxml/blob/master/LICENSE.txt>`__ | *Not yet evaluated.* |
69-
+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
57+
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
58+
| **Package** | **Version** | **License** | **Dependencies** |
59+
+=====================================================================+=============+========================================================================================+======================+
60+
| `pytest <https://GitHub.com/pytest-dev/pytest>`__ | ≥7.4.0 | `MIT <https://GitHub.com/pytest-dev/pytest/blob/master/LICENSE>`__ | *Not yet evaluated.* |
61+
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
62+
| `pytest-cov <https://GitHub.com/pytest-dev/pytest-cov>`__ | ≥4.1.0 | `MIT <https://GitHub.com/pytest-dev/pytest-cov/blob/master/LICENSE>`__ | *Not yet evaluated.* |
63+
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
64+
| `Coverage <https://GitHub.com/nedbat/coveragepy>`__ | ≥7.3 | `Apache License, 2.0 <https://GitHub.com/nedbat/coveragepy/blob/master/LICENSE.txt>`__ | *Not yet evaluated.* |
65+
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
66+
| `mypy <https://GitHub.com/python/mypy>`__ | ≥1.5 | `MIT <https://GitHub.com/python/mypy/blob/master/LICENSE>`__ | *Not yet evaluated.* |
67+
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
68+
| `typing-extensions <https://GitHub.com/python/typing_extensions>`__ | ≥4.7.1 | `PSF-2.0 <https://github.com/python/typing_extensions/blob/main/LICENSE>`__ | *Not yet evaluated.* |
69+
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
70+
| `lxml <https://GitHub.com/lxml/lxml>`__ | ≥4.9 | `BSD 3-Clause <https://GitHub.com/lxml/lxml/blob/master/LICENSE.txt>`__ | *Not yet evaluated.* |
71+
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
7072

7173

7274
.. _dependency-documentation:

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@
206206
extlinks = {
207207
"ghissue": ('https://GitHub.com/edaa-org/pySystemRDLModel/issues/%s', 'issue #'),
208208
"ghpull": ('https://GitHub.com/edaa-org/pySystemRDLModel/pull/%s', 'pull request #'),
209-
"ghsrc": ('https://GitHub.com/edaa-org/pySystemRDLModel/blob/main/%s?ts=2', ""),
209+
"ghsrc": ('https://GitHub.com/edaa-org/pySystemRDLModel/blob/main/%s?ts=2', None),
210210
}
211211

212212

pySystemRDLModel/__init__.py

Lines changed: 126 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -44,37 +44,42 @@
4444
__email__ = "[email protected]"
4545
__copyright__ = "2023-2023, Patrick Lehmann"
4646
__license__ = "Apache License, Version 2.0"
47-
__version__ = "0.2.1"
47+
__version__ = "0.2.2"
4848

4949

5050
@export
5151
@unique
5252
class SystemRDLVersion(Enum):
53-
Any = -1
54-
SystemRDL2005 = 2005
55-
SystemRDL2009 = 2009
56-
SystemRDL2012 = 2012
57-
SystemRDL2017 = 2017
53+
Any = -1
54+
55+
SystemRDL2005 = 2005
56+
SystemRDL2009 = 2009
57+
SystemRDL2012 = 2012
58+
SystemRDL2017 = 2017
59+
60+
Latest = 10000
5861

5962
__VERSION_MAPPINGS__: Dict[Union[int, str], Enum] = {
60-
-1: Any,
61-
5: SystemRDL2005,
62-
9: SystemRDL2009,
63-
12: SystemRDL2012,
64-
17: SystemRDL2017,
65-
2005: SystemRDL2005,
66-
2009: SystemRDL2009,
67-
2012: SystemRDL2012,
68-
2017: SystemRDL2017,
69-
"Any": Any,
70-
"05": SystemRDL2005,
71-
"09": SystemRDL2009,
72-
"12": SystemRDL2012,
73-
"17": SystemRDL2017,
74-
"2005": SystemRDL2005,
75-
"2009": SystemRDL2009,
76-
"2012": SystemRDL2012,
77-
"2017": SystemRDL2017,
63+
-1: Any,
64+
5: SystemRDL2005,
65+
9: SystemRDL2009,
66+
12: SystemRDL2012,
67+
17: SystemRDL2017,
68+
2005: SystemRDL2005,
69+
2009: SystemRDL2009,
70+
2012: SystemRDL2012,
71+
2017: SystemRDL2017,
72+
10000: Latest,
73+
"Any": Any,
74+
"05": SystemRDL2005,
75+
"09": SystemRDL2009,
76+
"12": SystemRDL2012,
77+
"17": SystemRDL2017,
78+
"2005": SystemRDL2005,
79+
"2009": SystemRDL2009,
80+
"2012": SystemRDL2012,
81+
"2017": SystemRDL2017,
82+
"Latest": SystemRDL2017,
7883
}
7984

8085
def __init__(self, *_):
@@ -91,35 +96,110 @@ def Parse(cls, value: Union[int, str]) -> "SystemRDLVersion":
9196
except KeyError:
9297
raise ValueError(f"Value '{value!s}' cannot be parsed to member of {cls.__name__}.")
9398

94-
def __lt__(self, other):
95-
return self.value < other.value
96-
97-
def __le__(self, other):
98-
return self.value <= other.value
99-
100-
def __gt__(self, other):
101-
return self.value > other.value
99+
def __lt__(self, other: Any) -> bool:
100+
"""
101+
Compare two (System)Verilog versions if the version is less than the second operand.
102102
103-
def __ge__(self, other):
104-
return self.value >= other.value
105-
106-
def __ne__(self, other):
107-
return self.value != other.value
108-
109-
def __eq__(self, other):
110-
if (self is self.__class__.Any) or (other is self.__class__.Any):
111-
return True
103+
:param other: Parameter to compare against.
104+
:returns: True if version is less than the second operand.
105+
:raises TypeError: If parameter ``other`` is not of type :class:`SystemRDLVersion`.
106+
"""
107+
if isinstance(other, SystemRDLVersion):
108+
return self.value < other.value
109+
else:
110+
raise TypeError("Second operand is not of type 'SystemRDLVersion'.")
111+
112+
def __le__(self, other: Any) -> bool:
113+
"""
114+
Compare two (System)Verilog versions if the version is less or equal than the second operand.
115+
116+
:param other: Parameter to compare against.
117+
:returns: True if version is less or equal than the second operand.
118+
:raises TypeError: If parameter ``other`` is not of type :class:`SystemRDLVersion`.
119+
"""
120+
if isinstance(other, SystemRDLVersion):
121+
return self.value <= other.value
122+
else:
123+
raise TypeError("Second operand is not of type 'SystemRDLVersion'.")
124+
125+
def __gt__(self, other: Any) -> bool:
126+
"""
127+
Compare two (System)Verilog versions if the version is greater than the second operand.
128+
129+
:param other: Parameter to compare against.
130+
:returns: True if version is greater than the second operand.
131+
:raises TypeError: If parameter ``other`` is not of type :class:`SystemRDLVersion`.
132+
"""
133+
if isinstance(other, SystemRDLVersion):
134+
return self.value > other.value
112135
else:
113-
return self.value == other.value
136+
raise TypeError("Second operand is not of type 'SystemRDLVersion'.")
137+
138+
def __ge__(self, other: Any) -> bool:
139+
"""
140+
Compare two (System)Verilog versions if the version is greater or equal than the second operand.
141+
142+
:param other: Parameter to compare against.
143+
:returns: True if version is greater or equal than the second operand.
144+
:raises TypeError: If parameter ``other`` is not of type :class:`SystemRDLVersion`.
145+
"""
146+
if isinstance(other, SystemRDLVersion):
147+
return self.value >= other.value
148+
else:
149+
raise TypeError("Second operand is not of type 'SystemRDLVersion'.")
150+
151+
def __ne__(self, other: Any) -> bool:
152+
"""
153+
Compare two (System)Verilog versions if the version is unequal to the second operand.
154+
155+
:param other: Parameter to compare against.
156+
:returns: True if version is unequal to the second operand.
157+
:raises TypeError: If parameter ``other`` is not of type :class:`SystemRDLVersion`.
158+
"""
159+
if isinstance(other, SystemRDLVersion):
160+
return self.value != other.value
161+
else:
162+
raise TypeError("Second operand is not of type 'SystemRDLVersion'.")
163+
164+
def __eq__(self, other: Any) -> bool:
165+
"""
166+
Compare two (System)Verilog versions if the version is equal to the second operand.
167+
168+
:param other: Parameter to compare against.
169+
:returns: True if version is equal to the second operand.
170+
:raises TypeError: If parameter ``other`` is not of type :class:`SystemRDLVersion`.
171+
"""
172+
if isinstance(other, SystemRDLVersion):
173+
if (self is self.__class__.Any) or (other is self.__class__.Any):
174+
return True
175+
else:
176+
return self.value == other.value
177+
else:
178+
raise TypeError("Second operand is not of type 'SystemRDLVersion'.")
114179

115180
def __str__(self) -> str:
116-
if self.value == -1:
181+
"""
182+
Formats the SystemRDLVersion version to pattern ``SystemRDL'xx``.
183+
184+
:return: Formatted SystemRDL version.
185+
"""
186+
if self.value == self.Any.value:
117187
return "SystemRDL'Any"
118-
else:
119-
return f"SystemRDL'{str(self.value)[-2:]}"
188+
if self.value == self.Latest.value:
189+
return "SystemRDL'Latest"
190+
191+
year = str(self.value)[-2:]
192+
return f"SystemRDL'{year}"
120193

121194
def __repr__(self) -> str:
122-
if self.value == -1:
195+
"""
196+
Formats the SystemRDL version to pattern ``xxxx``.
197+
198+
:return: Formatted SystemRDL version.
199+
"""
200+
if self.value == self.Any.value:
123201
return "Any"
202+
elif self.value == self.Latest.value:
203+
return "Latest"
124204
else:
125205
return str(self.value)

tests/requirements.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
-r ../requirements.txt
22

33
# Coverage collection
4-
Coverage>=7.0
4+
Coverage >= 7.3
55

66
# Test Runner
7-
pytest>=7.2.0
8-
pytest-cov>=4.0.0
7+
pytest >= 7.4.0
8+
pytest-cov >= 4.1.0
99

1010
# Static Type Checking
11-
mypy >= 1.2
11+
mypy >= 1.5
12+
typing_extensions >= 4.7.1
1213
lxml>=4.9

tests/unit/Instantiate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def test_2012(self):
9999
print(version)
100100
print(version.value)
101101

102-
def test_2019(self):
102+
def test_2017(self):
103103
versions = (
104104
SystemRDLVersion.Parse(17),
105105
SystemRDLVersion.Parse(2017),

0 commit comments

Comments
 (0)