From c5895befdc231e7af8b57b8704a65539c56d3880 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Thu, 15 Feb 2024 11:56:14 +0100 Subject: [PATCH 1/3] Improve code --- .github/workflows/main.yaml | 2 +- radl/radl.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 7c7509a..c9d6abe 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -25,7 +25,7 @@ jobs: run: pycodestyle --max-line-length=120 --ignore=E402,W504,W605,E722,E741 . --exclude=doc - name: Unit tests - run: python -m coverage run --source=. -m unittest discover -s test -p '*.py' + run: python -m coverage run --source=. -m unittest discover -v -s test -p '*.py' - name: Generate XML coverage report run: python -m coverage xml diff --git a/radl/radl.py b/radl/radl.py index 77b7c94..c0282cd 100644 --- a/radl/radl.py +++ b/radl/radl.py @@ -16,7 +16,7 @@ import copy import re -from distutils.version import LooseVersion +from packaging.version import Version try: unicode @@ -797,7 +797,7 @@ def isNewerThan(self, other): if not other.getValue("version"): return False else: - return LooseVersion(self.getValue("version")) > LooseVersion(other.getValue("version")) + return Version(self.getValue("version")) > Version(other.getValue("version")) else: return True else: From 53bf5402b8fdec5c3379b4688addaacef564bea0 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Thu, 15 Feb 2024 11:59:05 +0100 Subject: [PATCH 2/3] Improve code --- .github/workflows/main.yaml | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index c9d6abe..809f742 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -19,7 +19,7 @@ jobs: python-version: '3.10' - name: Install dependencies - run: python -m pip install pycodestyle ply coverage + run: python -m pip install pycodestyle ply coverage packaging - name: Check code style run: pycodestyle --max-line-length=120 --ignore=E402,W504,W605,E722,E741 . --exclude=doc diff --git a/setup.py b/setup.py index 230357d..44918de 100644 --- a/setup.py +++ b/setup.py @@ -31,4 +31,4 @@ "Python 2 and Python 3"), description="Resource and Application Description Language (RADL) parser.", platforms=["any"], - install_requires=["ply"]) + install_requires=["ply", "packaging"]) From 96a1f5b958ce9c9e8d5aaabf8b4f08616ec49d2e Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Thu, 15 Feb 2024 12:00:24 +0100 Subject: [PATCH 3/3] Improve code --- test/TestRADL.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/TestRADL.py b/test/TestRADL.py index c4c6e83..7d866d9 100644 --- a/test/TestRADL.py +++ b/test/TestRADL.py @@ -387,7 +387,6 @@ def test_contextualize_options(self): self.assertEqual(r.contextualize.options['ansible_version'].getLogOperator(), '<=') radl_json = dump_radl_json(r) - print(radl_json) r = parse_radl_json(radl_json) r.check() self.assertEqual(len(r.contextualize.options), 1) @@ -408,7 +407,6 @@ def test_empty_configure(self): self.assertEqual(r.configures[0].recipes, None) radl_json = dump_radl_json(r) - print(radl_json) r = parse_radl_json(radl_json) r.check() self.assertEqual(r.configures[0].recipes, None) @@ -424,7 +422,6 @@ def test_escape_quote(self): self.assertEqual(r.systems[0].getValue("some_value"), "some ' some") radl_json = dump_radl_json(r) - print(radl_json) r = parse_radl_json(radl_json) r.check() self.assertEqual(r.systems[0].getValue("some_value"), "some ' some")