From 69b57837bae889a6d759fb57ee58aa296f4f5098 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Wed, 2 Aug 2023 23:39:54 +0200 Subject: [PATCH 1/3] Added doc-strings and added Latest version. --- pySVModel/__init__.py | 216 ++++++++++++++++++++++++++++++------------ 1 file changed, 157 insertions(+), 59 deletions(-) diff --git a/pySVModel/__init__.py b/pySVModel/__init__.py index a313aa7..93119df 100644 --- a/pySVModel/__init__.py +++ b/pySVModel/__init__.py @@ -44,54 +44,58 @@ __email__ = "Paebbels@gmail.com" __copyright__ = "2021-2023, Patrick Lehmann" __license__ = "Apache License, Version 2.0" -__version__ = "0.4.0" +__version__ = "0.4.1" @export @unique class SystemVerilogVersion(Enum): - Any = -1 + Any = -1 - Verilog95 = 95 - Verilog2001 = 1 - Verilog2005 = 5 + Verilog95 = 95 + Verilog2001 = 1 + Verilog2005 = 5 - SystemVerilog2005 = 2005 - SystemVerilog2009 = 2009 - SystemVerilog2012 = 2012 - SystemVerilog2017 = 2017 + SystemVerilog2005 = 2005 + SystemVerilog2009 = 2009 + SystemVerilog2012 = 2012 + SystemVerilog2017 = 2017 + + Latest = 10000 __VERSION_MAPPINGS__: Dict[Union[int, str], Enum] = { - -1: Any, - 95: Verilog95, - 1: Verilog2001, - 5: Verilog2005, - # 5: SystemVerilog2005, # prefer Verilog on numbers below 2000 - 9: SystemVerilog2009, - 12: SystemVerilog2012, - 17: SystemVerilog2017, - 1995: Verilog95, - 2001: Verilog2001, - # 2005: Verilog2005, # prefer SystemVerilog on numbers above 2000 - 2005: SystemVerilog2005, - 2009: SystemVerilog2009, - 2012: SystemVerilog2012, - 2017: SystemVerilog2017, - "Any": Any, - "95": Verilog95, - "01": Verilog2001, - "05": Verilog2005, - # "05": SystemVerilog2005, # prefer Verilog on numbers below 2000 - "09": SystemVerilog2009, - "12": SystemVerilog2012, - "17": SystemVerilog2017, - "1995": Verilog95, - "2001": Verilog2001, - # "2005": Verilog2005, # prefer SystemVerilog on numbers above 2000 - "2005": SystemVerilog2005, - "2009": SystemVerilog2009, - "2012": SystemVerilog2012, - "2017": SystemVerilog2017, + -1: Any, + 95: Verilog95, + 1: Verilog2001, + 5: Verilog2005, + # 5: SystemVerilog2005, # prefer Verilog on numbers below 2000 + 9: SystemVerilog2009, + 12: SystemVerilog2012, + 17: SystemVerilog2017, + 1995: Verilog95, + 2001: Verilog2001, + # 2005: Verilog2005, # prefer SystemVerilog on numbers above 2000 + 2005: SystemVerilog2005, + 2009: SystemVerilog2009, + 2012: SystemVerilog2012, + 2017: SystemVerilog2017, + 10000: Latest, + "Any": Any, + "95": Verilog95, + "01": Verilog2001, + "05": Verilog2005, + # "05": SystemVerilog2005, # prefer Verilog on numbers below 2000 + "09": SystemVerilog2009, + "12": SystemVerilog2012, + "17": SystemVerilog2017, + "1995": Verilog95, + "2001": Verilog2001, + # "2005": Verilog2005, # prefer SystemVerilog on numbers above 2000 + "2005": SystemVerilog2005, + "2009": SystemVerilog2009, + "2012": SystemVerilog2012, + "2017": SystemVerilog2017, + "Latest": Latest } def __init__(self, *_): @@ -107,37 +111,131 @@ def Parse(cls, value: Union[int, str]) -> "SystemVerilogVersion": except KeyError: raise ValueError("Value '{0!s}' cannot be parsed to member of {1}.".format(value, cls.__name__)) - def __lt__(self, other) -> bool: - 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 __le__(self, other) -> bool: - return self.value <= other.value + :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:`SystemVerilogVersion`. + """ + if isinstance(other, SystemVerilogVersion): + return self.value < other.value + else: + raise TypeError("Second operand is not of type 'SystemVerilogVersion'.") + + 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:`SystemVerilogVersion`. + """ + if isinstance(other, SystemVerilogVersion): + return self.value <= other.value + else: + raise TypeError("Second operand is not of type 'SystemVerilogVersion'.") + + 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:`SystemVerilogVersion`. + """ + if isinstance(other, SystemVerilogVersion): + return self.value > other.value + else: + raise TypeError("Second operand is not of type 'SystemVerilogVersion'.") + + 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:`SystemVerilogVersion`. + """ + if isinstance(other, SystemVerilogVersion): + return self.value >= other.value + else: + raise TypeError("Second operand is not of type 'SystemVerilogVersion'.") + + 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:`SystemVerilogVersion`. + """ + if isinstance(other, SystemVerilogVersion): + return self.value != other.value + else: + raise TypeError("Second operand is not of type 'SystemVerilogVersion'.") + + 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:`SystemVerilogVersion`. + """ + if isinstance(other, SystemVerilogVersion): + 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 'SystemVerilogVersion'.") - def __gt__(self, other) -> bool: - return self.value > other.value + @property + def IsVerilog(self) -> bool: + """ + Checks if the version is a (classic) Verilog version. - def __ge__(self, other) -> bool: - return self.value >= other.value + :returns: True if version is a (classic) Verilog version. + """ + return self in (self.Verilog95, self.Verilog2001, self.Verilog2005) - def __ne__(self, other) -> bool: - return self.value != other.value + @property + def IsSystemVerilog(self) -> bool: + """ + Checks if the version is a SystemVerilog version. - def __eq__(self, other) -> bool: - if (self is self.__class__.Any) or (other is self.__class__.Any): - return True - else: - return self.value == other.value + :returns: True if version is a SystemVerilog version. + """ + return self in (self.SystemVerilog2005, self.SystemVerilog2009, self.SystemVerilog2012, self.SystemVerilog2017) def __str__(self) -> str: - if self.value == -1: + """ + Formats the SystemVerilog version to pattern ``SV'xx`` or in case of classic Verilog to ``Verilog'xx``. + + :return: Formatted (System)Verilog version. + """ + if self.value == self.Any.value: return "SV'Any" - elif self.value < self.SystemVerilog2005.value: - return "Verilog'" + str(self.value)[-2:] + if self.value == self.Latest.value: + return "SV'Latest" + + year = str(self.value)[-2:] + if self.value < self.SystemVerilog2005.value: + return f"Verilog'{year}" else: - return "SV'" + str(self.value)[-2:] + return f"SV'{year}" def __repr__(self) -> str: - if self.value == -1: + """ + Formats the (System)Verilog version to pattern ``xxxx``. + + :return: Formatted (System)Verilog version. + """ + if self.value == self.Any.value: return "Any" + elif self.value == self.Latest.value: + return "Latest" else: return str(self.value) From 61f0e674fa7b1b21df91aa2f1d2f93fffb2f9ae3 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Sun, 13 Aug 2023 23:19:53 +0200 Subject: [PATCH 2/3] Fixed InterSphinx configuration. --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 7a98d3a..f34a665 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -206,7 +206,7 @@ extlinks = { "ghissue": ('https://GitHub.com/edaa-org/pySVModel/issues/%s', 'issue #'), "ghpull": ('https://GitHub.com/edaa-org/pySVModel/pull/%s', 'pull request #'), - "ghsrc": ('https://GitHub.com/edaa-org/pySVModel/blob/main/%s?ts=2', ""), + "ghsrc": ('https://GitHub.com/edaa-org/pySVModel/blob/main/%s?ts=2', None), } From 113c1ac0ab3478908baa658a6fc9f660d9ddc9d4 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Sun, 13 Aug 2023 23:20:04 +0200 Subject: [PATCH 3/3] Bumped dependencies. --- doc/Dependency.rst | 28 +++++++++++++++------------- tests/requirements.txt | 9 +++++---- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/doc/Dependency.rst b/doc/Dependency.rst index bbeeaea..0b0069a 100644 --- a/doc/Dependency.rst +++ b/doc/Dependency.rst @@ -54,19 +54,21 @@ the mandatory dependencies too. .. rubric:: Dependency List -+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ -| **Package** | **Version** | **License** | **Dependencies** | -+===========================================================+=============+========================================================================================+======================+ -| `pytest `__ | ≥7.2.0 | `MIT `__ | *Not yet evaluated.* | -+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ -| `pytest-cov `__ | ≥4.0.0 | `MIT `__ | *Not yet evaluated.* | -+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ -| `Coverage `__ | ≥7.0 | `Apache License, 2.0 `__ | *Not yet evaluated.* | -+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ -| `mypy `__ | ≥1.2 | `MIT `__ | *Not yet evaluated.* | -+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ -| `lxml `__ | ≥4.9 | `BSD 3-Clause `__ | *Not yet evaluated.* | -+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ ++---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ +| **Package** | **Version** | **License** | **Dependencies** | ++=====================================================================+=============+========================================================================================+======================+ +| `pytest `__ | ≥7.4.0 | `MIT `__ | *Not yet evaluated.* | ++---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ +| `pytest-cov `__ | ≥4.1.0 | `MIT `__ | *Not yet evaluated.* | ++---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ +| `Coverage `__ | ≥7.3 | `Apache License, 2.0 `__ | *Not yet evaluated.* | ++---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ +| `mypy `__ | ≥1.5 | `MIT `__ | *Not yet evaluated.* | ++---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ +| `typing-extensions `__ | ≥4.7.1 | `PSF-2.0 `__ | *Not yet evaluated.* | ++---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ +| `lxml `__ | ≥4.9 | `BSD 3-Clause `__ | *Not yet evaluated.* | ++---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ .. _dependency-documentation: diff --git a/tests/requirements.txt b/tests/requirements.txt index 6407e55..6904298 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -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