Skip to content

Commit

Permalink
v0.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Paebbels authored Aug 15, 2023
2 parents 3d6e478 + 2f073e8 commit e08c4a5
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 65 deletions.
28 changes: 15 additions & 13 deletions doc/Dependency.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,21 @@ the mandatory dependencies too.
.. rubric:: Dependency List

+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| **Package** | **Version** | **License** | **Dependencies** |
+===========================================================+=============+========================================================================================+======================+
| `pytest <https://GitHub.com/pytest-dev/pytest>`__ | ≥7.2.0 | `MIT <https://GitHub.com/pytest-dev/pytest/blob/master/LICENSE>`__ | *Not yet evaluated.* |
+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| `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.* |
+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| `Coverage <https://GitHub.com/nedbat/coveragepy>`__ | ≥7.0 | `Apache License, 2.0 <https://GitHub.com/nedbat/coveragepy/blob/master/LICENSE.txt>`__ | *Not yet evaluated.* |
+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| `mypy <https://GitHub.com/python/mypy>`__ | ≥1.2 | `MIT <https://GitHub.com/python/mypy/blob/master/LICENSE>`__ | *Not yet evaluated.* |
+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| `lxml <https://GitHub.com/lxml/lxml>`__ | ≥4.9 | `BSD 3-Clause <https://GitHub.com/lxml/lxml/blob/master/LICENSE.txt>`__ | *Not yet evaluated.* |
+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| **Package** | **Version** | **License** | **Dependencies** |
+=====================================================================+=============+========================================================================================+======================+
| `pytest <https://GitHub.com/pytest-dev/pytest>`__ | ≥7.4.0 | `MIT <https://GitHub.com/pytest-dev/pytest/blob/master/LICENSE>`__ | *Not yet evaluated.* |
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| `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.* |
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| `Coverage <https://GitHub.com/nedbat/coveragepy>`__ | ≥7.3 | `Apache License, 2.0 <https://GitHub.com/nedbat/coveragepy/blob/master/LICENSE.txt>`__ | *Not yet evaluated.* |
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| `mypy <https://GitHub.com/python/mypy>`__ | ≥1.5 | `MIT <https://GitHub.com/python/mypy/blob/master/LICENSE>`__ | *Not yet evaluated.* |
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| `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.* |
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| `lxml <https://GitHub.com/lxml/lxml>`__ | ≥4.9 | `BSD 3-Clause <https://GitHub.com/lxml/lxml/blob/master/LICENSE.txt>`__ | *Not yet evaluated.* |
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+


.. _dependency-documentation:
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
extlinks = {
"ghissue": ('https://GitHub.com/edaa-org/pySystemRDLModel/issues/%s', 'issue #'),
"ghpull": ('https://GitHub.com/edaa-org/pySystemRDLModel/pull/%s', 'pull request #'),
"ghsrc": ('https://GitHub.com/edaa-org/pySystemRDLModel/blob/main/%s?ts=2', ""),
"ghsrc": ('https://GitHub.com/edaa-org/pySystemRDLModel/blob/main/%s?ts=2', None),
}


Expand Down
172 changes: 126 additions & 46 deletions pySystemRDLModel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,37 +44,42 @@
__email__ = "Paebbels@gmail.com"
__copyright__ = "2023-2023, Patrick Lehmann"
__license__ = "Apache License, Version 2.0"
__version__ = "0.2.1"
__version__ = "0.2.2"


@export
@unique
class SystemRDLVersion(Enum):
Any = -1
SystemRDL2005 = 2005
SystemRDL2009 = 2009
SystemRDL2012 = 2012
SystemRDL2017 = 2017
Any = -1

SystemRDL2005 = 2005
SystemRDL2009 = 2009
SystemRDL2012 = 2012
SystemRDL2017 = 2017

Latest = 10000

__VERSION_MAPPINGS__: Dict[Union[int, str], Enum] = {
-1: Any,
5: SystemRDL2005,
9: SystemRDL2009,
12: SystemRDL2012,
17: SystemRDL2017,
2005: SystemRDL2005,
2009: SystemRDL2009,
2012: SystemRDL2012,
2017: SystemRDL2017,
"Any": Any,
"05": SystemRDL2005,
"09": SystemRDL2009,
"12": SystemRDL2012,
"17": SystemRDL2017,
"2005": SystemRDL2005,
"2009": SystemRDL2009,
"2012": SystemRDL2012,
"2017": SystemRDL2017,
-1: Any,
5: SystemRDL2005,
9: SystemRDL2009,
12: SystemRDL2012,
17: SystemRDL2017,
2005: SystemRDL2005,
2009: SystemRDL2009,
2012: SystemRDL2012,
2017: SystemRDL2017,
10000: Latest,
"Any": Any,
"05": SystemRDL2005,
"09": SystemRDL2009,
"12": SystemRDL2012,
"17": SystemRDL2017,
"2005": SystemRDL2005,
"2009": SystemRDL2009,
"2012": SystemRDL2012,
"2017": SystemRDL2017,
"Latest": SystemRDL2017,
}

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

def __lt__(self, other):
return self.value < other.value

def __le__(self, other):
return self.value <= other.value

def __gt__(self, other):
return self.value > other.value
def __lt__(self, other: Any) -> bool:
"""
Compare two (System)Verilog versions if the version is less than the second operand.
def __ge__(self, other):
return self.value >= other.value

def __ne__(self, other):
return self.value != other.value

def __eq__(self, other):
if (self is self.__class__.Any) or (other is self.__class__.Any):
return True
:param other: Parameter to compare against.
:returns: True if version is less than the second operand.
:raises TypeError: If parameter ``other`` is not of type :class:`SystemRDLVersion`.
"""
if isinstance(other, SystemRDLVersion):
return self.value < other.value
else:
raise TypeError("Second operand is not of type 'SystemRDLVersion'.")

def __le__(self, other: Any) -> bool:
"""
Compare two (System)Verilog versions if the version is less or equal than the second operand.
:param other: Parameter to compare against.
:returns: True if version is less or equal than the second operand.
:raises TypeError: If parameter ``other`` is not of type :class:`SystemRDLVersion`.
"""
if isinstance(other, SystemRDLVersion):
return self.value <= other.value
else:
raise TypeError("Second operand is not of type 'SystemRDLVersion'.")

def __gt__(self, other: Any) -> bool:
"""
Compare two (System)Verilog versions if the version is greater than the second operand.
:param other: Parameter to compare against.
:returns: True if version is greater than the second operand.
:raises TypeError: If parameter ``other`` is not of type :class:`SystemRDLVersion`.
"""
if isinstance(other, SystemRDLVersion):
return self.value > other.value
else:
return self.value == other.value
raise TypeError("Second operand is not of type 'SystemRDLVersion'.")

def __ge__(self, other: Any) -> bool:
"""
Compare two (System)Verilog versions if the version is greater or equal than the second operand.
:param other: Parameter to compare against.
:returns: True if version is greater or equal than the second operand.
:raises TypeError: If parameter ``other`` is not of type :class:`SystemRDLVersion`.
"""
if isinstance(other, SystemRDLVersion):
return self.value >= other.value
else:
raise TypeError("Second operand is not of type 'SystemRDLVersion'.")

def __ne__(self, other: Any) -> bool:
"""
Compare two (System)Verilog versions if the version is unequal to the second operand.
:param other: Parameter to compare against.
:returns: True if version is unequal to the second operand.
:raises TypeError: If parameter ``other`` is not of type :class:`SystemRDLVersion`.
"""
if isinstance(other, SystemRDLVersion):
return self.value != other.value
else:
raise TypeError("Second operand is not of type 'SystemRDLVersion'.")

def __eq__(self, other: Any) -> bool:
"""
Compare two (System)Verilog versions if the version is equal to the second operand.
:param other: Parameter to compare against.
:returns: True if version is equal to the second operand.
:raises TypeError: If parameter ``other`` is not of type :class:`SystemRDLVersion`.
"""
if isinstance(other, SystemRDLVersion):
if (self is self.__class__.Any) or (other is self.__class__.Any):
return True
else:
return self.value == other.value
else:
raise TypeError("Second operand is not of type 'SystemRDLVersion'.")

def __str__(self) -> str:
if self.value == -1:
"""
Formats the SystemRDLVersion version to pattern ``SystemRDL'xx``.
:return: Formatted SystemRDL version.
"""
if self.value == self.Any.value:
return "SystemRDL'Any"
else:
return f"SystemRDL'{str(self.value)[-2:]}"
if self.value == self.Latest.value:
return "SystemRDL'Latest"

year = str(self.value)[-2:]
return f"SystemRDL'{year}"

def __repr__(self) -> str:
if self.value == -1:
"""
Formats the SystemRDL version to pattern ``xxxx``.
:return: Formatted SystemRDL version.
"""
if self.value == self.Any.value:
return "Any"
elif self.value == self.Latest.value:
return "Latest"
else:
return str(self.value)
9 changes: 5 additions & 4 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
-r ../requirements.txt

# Coverage collection
Coverage>=7.0
Coverage >= 7.3

# Test Runner
pytest>=7.2.0
pytest-cov>=4.0.0
pytest >= 7.4.0
pytest-cov >= 4.1.0

# Static Type Checking
mypy >= 1.2
mypy >= 1.5
typing_extensions >= 4.7.1
lxml>=4.9
2 changes: 1 addition & 1 deletion tests/unit/Instantiate.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def test_2012(self):
print(version)
print(version.value)

def test_2019(self):
def test_2017(self):
versions = (
SystemRDLVersion.Parse(17),
SystemRDLVersion.Parse(2017),
Expand Down

0 comments on commit e08c4a5

Please sign in to comment.