From 6e36311e6deac269bbcf7d757da3b7150fe2899c Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Mon, 26 Sep 2022 11:08:56 +0200 Subject: [PATCH] Release of 0.4.1 --- CHANGELOG.md | 5 +++++ qgis_plugin_repo/dispatcher.py | 4 ++-- qgis_plugin_repo/merger.py | 16 ---------------- tests/test_merger.py | 29 +++++++++++++++-------------- 4 files changed, 22 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index faad194..bc87739 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## Unreleased +## 0.4.1 - 2022-09-26 + +* Remove some print statements +* Fix if the destination is an empty file + ## 0.4.0 - 2022-09-22 * Enable Python 3.10 diff --git a/qgis_plugin_repo/dispatcher.py b/qgis_plugin_repo/dispatcher.py index c2edb03..dbca402 100644 --- a/qgis_plugin_repo/dispatcher.py +++ b/qgis_plugin_repo/dispatcher.py @@ -15,10 +15,10 @@ class Dispatcher: - def __init__(self, input_uri: Union[Path, str], outputs_uri: List[str]): + def __init__(self, input_uri: Union[Path, str], outputs_uri: List[Union[Path, str]]): """ Constructor. """ self.input_uri = input_uri - if is_url: + if is_url(input_uri): self.input_parser = ET.fromstring(requests.get(self.input_uri).content) else: self.input_parser = ET.parse(self.input_uri.absolute()).getroot() diff --git a/qgis_plugin_repo/merger.py b/qgis_plugin_repo/merger.py index fafe833..99849a9 100644 --- a/qgis_plugin_repo/merger.py +++ b/qgis_plugin_repo/merger.py @@ -86,22 +86,6 @@ def xml_output_parser(self) -> ET.Element: self.output_parser = self.output_tree.getroot() return self.output_parser - def input_is_url(self) -> bool: - """ Check if the input is a URL. """ - if isinstance(self.input_uri, Path): - return False - - path = Path(self.input_uri) - if path.exists(): - return False - - # noinspection PyBroadException - try: - urlparse(self.input_uri) - return True - except Exception: - return False - @staticmethod def plugins(parser) -> list: """ Return the plugins in the XML file. """ diff --git a/tests/test_merger.py b/tests/test_merger.py index 657cedb..64a8441 100644 --- a/tests/test_merger.py +++ b/tests/test_merger.py @@ -5,6 +5,7 @@ from qgis_plugin_repo.dispatcher import Dispatcher from qgis_plugin_repo.merger import Merger, Plugin +from qgis_plugin_repo.tools import is_url __copyright__ = 'Copyright 2021, 3Liz' __license__ = 'GPL version 3' @@ -43,7 +44,7 @@ def test_empty_repo(self): merger.xml_input_parser() input_plugins = merger.plugins(merger.input_parser) self.assertEqual(len(input_plugins), 1) - self.assertFalse(merger.input_is_url()) + self.assertFalse(is_url(merger.input_uri)) merger.xml_output_parser() output_plugins = [] @@ -66,7 +67,7 @@ def test_existing_repo_stable(self): merger.xml_input_parser() input_plugins = merger.plugins(merger.input_parser) self.assertEqual(len(input_plugins), 1) - self.assertFalse(merger.input_is_url()) + self.assertFalse(is_url(merger.input_uri)) merger.xml_output_parser() output_plugins = [ @@ -100,7 +101,7 @@ def test_existing_repo_experimental(self): merger.xml_input_parser() input_plugins = merger.plugins(merger.input_parser) self.assertEqual(len(input_plugins), 1) - self.assertFalse(merger.input_is_url()) + self.assertFalse(is_url(merger.input_uri)) merger.xml_output_parser() output_plugins = [ @@ -144,7 +145,7 @@ def test_url(self): Path("fixtures/plugins.xml"), "https://github.com/3liz/qgis-pgmetadata-plugin/releases/download/0.2.2/plugins.xml" ) - self.assertTrue(merger.input_is_url()) + self.assertTrue(is_url(merger.input_uri)) def test_count(self): """ Test to count plugins in an XML file. """ @@ -165,11 +166,11 @@ def test_dispatcher_plugin_stable(self): dispatcher = Dispatcher( Path("fixtures/pgmetadata_stable.xml"), [ - "fixtures/plugins_tmp-3.4.xml", - "fixtures/plugins_tmp-3.10.xml", - "fixtures/plugins_tmp-3.16.xml", - "fixtures/plugins_tmp-3.22.xml", - "fixtures/plugins_tmp-3.28.xml", + Path("fixtures/plugins_tmp-3.4.xml"), + Path("fixtures/plugins_tmp-3.10.xml"), + Path("fixtures/plugins_tmp-3.16.xml"), + Path("fixtures/plugins_tmp-3.22.xml"), + Path("fixtures/plugins_tmp-3.28.xml"), ] ) qgis_min, qgis_max = dispatcher.versions_for_plugin() @@ -189,11 +190,11 @@ def test_dispatcher_plugin_dev(self): dispatcher = Dispatcher( Path("fixtures/pgmetadata_experimental.xml"), [ - "fixtures/plugins_tmp-3.4.xml", - "fixtures/plugins_tmp-3.10.xml", - "fixtures/plugins_tmp-3.16.xml", - "fixtures/plugins_tmp-3.22.xml", - "fixtures/plugins_tmp-3.28.xml", + Path("fixtures/plugins_tmp-3.4.xml"), + Path("fixtures/plugins_tmp-3.10.xml"), + Path("fixtures/plugins_tmp-3.16.xml"), + Path("fixtures/plugins_tmp-3.22.xml"), + Path("fixtures/plugins_tmp-3.28.xml"), ] ) qgis_min, qgis_max = dispatcher.versions_for_plugin()