From cfc093d0e93349c6ba60ac66d61c8c58fc1a274a Mon Sep 17 00:00:00 2001 From: Alexander Bruy Date: Thu, 3 Jun 2021 13:44:39 +0300 Subject: [PATCH] separate otb provider into a plugin --- python/plugins/CMakeLists.txt | 1 + python/plugins/otbprovider/CMakeLists.txt | 4 ++ .../algs/otb => otbprovider}/OtbAlgorithm.py | 4 +- .../OtbAlgorithmProvider.py | 4 +- .../otb => otbprovider}/OtbChoiceWidget.py | 0 .../plugins/otbprovider/OtbProviderPlugin.py | 39 +++++++++++++++++++ .../algs/otb => otbprovider}/OtbUtils.py | 0 python/plugins/otbprovider/__init__.py | 27 +++++++++++++ python/plugins/otbprovider/metadata.txt | 17 ++++++++ python/plugins/processing/algs/CMakeLists.txt | 1 - .../processing/algs/otb/CMakeLists.txt | 2 - .../plugins/processing/algs/otb/__init__.py | 0 python/plugins/processing/core/Processing.py | 4 -- 13 files changed, 92 insertions(+), 11 deletions(-) create mode 100644 python/plugins/otbprovider/CMakeLists.txt rename python/plugins/{processing/algs/otb => otbprovider}/OtbAlgorithm.py (99%) rename python/plugins/{processing/algs/otb => otbprovider}/OtbAlgorithmProvider.py (99%) rename python/plugins/{processing/algs/otb => otbprovider}/OtbChoiceWidget.py (100%) create mode 100644 python/plugins/otbprovider/OtbProviderPlugin.py rename python/plugins/{processing/algs/otb => otbprovider}/OtbUtils.py (100%) create mode 100644 python/plugins/otbprovider/__init__.py create mode 100644 python/plugins/otbprovider/metadata.txt delete mode 100644 python/plugins/processing/algs/otb/CMakeLists.txt delete mode 100644 python/plugins/processing/algs/otb/__init__.py diff --git a/python/plugins/CMakeLists.txt b/python/plugins/CMakeLists.txt index d60305645f7..ebf9b87c5ff 100644 --- a/python/plugins/CMakeLists.txt +++ b/python/plugins/CMakeLists.txt @@ -55,6 +55,7 @@ endif() add_subdirectory(processing) add_subdirectory(sagaprovider) add_subdirectory(grassprovider) +add_subdirectory(otbprovider) add_subdirectory(MetaSearch) PY_COMPILE(staged-plugins "${PYTHON_OUTPUT_DIRECTORY}/plugins") diff --git a/python/plugins/otbprovider/CMakeLists.txt b/python/plugins/otbprovider/CMakeLists.txt new file mode 100644 index 00000000000..2122113fa47 --- /dev/null +++ b/python/plugins/otbprovider/CMakeLists.txt @@ -0,0 +1,4 @@ +file(GLOB PY_FILES *.py) +file(GLOB OTHER_FILES metadata.txt) + +PLUGIN_INSTALL(otbprovider . ${PY_FILES} ${OTHER_FILES}) diff --git a/python/plugins/processing/algs/otb/OtbAlgorithm.py b/python/plugins/otbprovider/OtbAlgorithm.py similarity index 99% rename from python/plugins/processing/algs/otb/OtbAlgorithm.py rename to python/plugins/otbprovider/OtbAlgorithm.py index 1065c630bb4..1e830611c1d 100644 --- a/python/plugins/processing/algs/otb/OtbAlgorithm.py +++ b/python/plugins/otbprovider/OtbAlgorithm.py @@ -51,8 +51,8 @@ from qgis.core import (Qgis, QgsProviderRegistry) from processing.core.parameters import getParameterFromString -from processing.algs.otb.OtbChoiceWidget import OtbParameterChoice -from processing.algs.otb.OtbUtils import OtbUtils +from .OtbChoiceWidget import OtbParameterChoice +from .OtbUtils import OtbUtils class OtbAlgorithm(QgsProcessingAlgorithm): diff --git a/python/plugins/processing/algs/otb/OtbAlgorithmProvider.py b/python/plugins/otbprovider/OtbAlgorithmProvider.py similarity index 99% rename from python/plugins/processing/algs/otb/OtbAlgorithmProvider.py rename to python/plugins/otbprovider/OtbAlgorithmProvider.py index 86b62dc6eba..4ef46581e3c 100755 --- a/python/plugins/processing/algs/otb/OtbAlgorithmProvider.py +++ b/python/plugins/otbprovider/OtbAlgorithmProvider.py @@ -35,8 +35,8 @@ from qgis.core import (Qgis, from qgis import utils from processing.core.ProcessingConfig import ProcessingConfig, Setting -from processing.algs.otb.OtbUtils import OtbUtils -from processing.algs.otb.OtbAlgorithm import OtbAlgorithm +from .OtbUtils import OtbUtils +from .OtbAlgorithm import OtbAlgorithm class OtbAlgorithmProvider(QgsProcessingProvider): diff --git a/python/plugins/processing/algs/otb/OtbChoiceWidget.py b/python/plugins/otbprovider/OtbChoiceWidget.py similarity index 100% rename from python/plugins/processing/algs/otb/OtbChoiceWidget.py rename to python/plugins/otbprovider/OtbChoiceWidget.py diff --git a/python/plugins/otbprovider/OtbProviderPlugin.py b/python/plugins/otbprovider/OtbProviderPlugin.py new file mode 100644 index 00000000000..87d17abad5a --- /dev/null +++ b/python/plugins/otbprovider/OtbProviderPlugin.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- + +""" +*************************************************************************** + OtbProviderPlugin.py + --------------------- + Date : June 2021 + Copyright : (C) 2021 by Alexander Bruy + Email : alexander dot bruy at gmail dot com +*************************************************************************** +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +*************************************************************************** +""" + +__author__ = 'Alexander Bruy' +__date__ = 'June 2021' +__copyright__ = '(C) 2021, Alexander Bruy' + + +from qgis.core import QgsApplication + +from otbprovider.OtbAlgorithmProvider import OtbAlgorithmProvider + + +class OtbProviderPlugin: + + def __init__(self): + self.provider = OtbAlgorithmProvider() + + def initGui(self): + QgsApplication.processingRegistry().addProvider(self.provider) + + def unload(self): + QgsApplication.processingRegistry().removeProvider(self.provider) diff --git a/python/plugins/processing/algs/otb/OtbUtils.py b/python/plugins/otbprovider/OtbUtils.py similarity index 100% rename from python/plugins/processing/algs/otb/OtbUtils.py rename to python/plugins/otbprovider/OtbUtils.py diff --git a/python/plugins/otbprovider/__init__.py b/python/plugins/otbprovider/__init__.py new file mode 100644 index 00000000000..142bb565530 --- /dev/null +++ b/python/plugins/otbprovider/__init__.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- + +""" +*************************************************************************** + __init__.py + --------------------- + Date : June 2021 + Copyright : (C) 2021 by Alexander Bruy + Email : alexander dot bruy at gmail dot com +*************************************************************************** +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +*************************************************************************** +""" + +__author__ = 'Alexander Bruy' +__date__ = 'June 2021' +__copyright__ = '(C) 2021, Alexander Bruy' + + +def classFactory(iface): + from otbprovider.OtbProviderPlugin import OtbProviderPlugin + return OtbProviderPlugin() diff --git a/python/plugins/otbprovider/metadata.txt b/python/plugins/otbprovider/metadata.txt new file mode 100644 index 00000000000..b43c6131430 --- /dev/null +++ b/python/plugins/otbprovider/metadata.txt @@ -0,0 +1,17 @@ +[general] +name=OrfeoToolbox provider +description=OrfeoToolbox Processing provider +about=OrfeoToolbox Processing provider +category=Analysis +version=2.12.99 +qgisMinimumVersion=3.0 + +author=Victor Olaya + +icon=:/images/themes/default/providerOtb.svg + +homepage=https://qgis.org +tracker=https://github.com/qgis/QGIS/issues +repository=https://github.com/qgis/QGIS + +hasProcessingProvider=yes diff --git a/python/plugins/processing/algs/CMakeLists.txt b/python/plugins/processing/algs/CMakeLists.txt index 7f1eda0a854..c24cc2592f1 100644 --- a/python/plugins/processing/algs/CMakeLists.txt +++ b/python/plugins/processing/algs/CMakeLists.txt @@ -2,7 +2,6 @@ file(GLOB PY_FILES *.py) add_subdirectory(help) add_subdirectory(gdal) -add_subdirectory(otb) add_subdirectory(qgis) PLUGIN_INSTALL(processing algs ${PY_FILES}) diff --git a/python/plugins/processing/algs/otb/CMakeLists.txt b/python/plugins/processing/algs/otb/CMakeLists.txt deleted file mode 100644 index af8369958ce..00000000000 --- a/python/plugins/processing/algs/otb/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -file(GLOB PY_FILES *.py) -PLUGIN_INSTALL(processing algs/otb ${PY_FILES}) diff --git a/python/plugins/processing/algs/otb/__init__.py b/python/plugins/processing/algs/otb/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/python/plugins/processing/core/Processing.py b/python/plugins/processing/core/Processing.py index 6bdd7301f26..f3bedc54e91 100644 --- a/python/plugins/processing/core/Processing.py +++ b/python/plugins/processing/core/Processing.py @@ -59,9 +59,6 @@ with QgsRuntimeProfiler.profile('Import QGIS Provider'): with QgsRuntimeProfiler.profile('Import GDAL Provider'): from processing.algs.gdal.GdalAlgorithmProvider import GdalAlgorithmProvider # NOQA -with QgsRuntimeProfiler.profile('Import OTB Provider'): - from processing.algs.otb.OtbAlgorithmProvider import OtbAlgorithmProvider # NOQA - with QgsRuntimeProfiler.profile('Import Script Provider'): from processing.script.ScriptAlgorithmProvider import ScriptAlgorithmProvider # NOQA @@ -112,7 +109,6 @@ class Processing(object): for c in [ QgisAlgorithmProvider, GdalAlgorithmProvider, - OtbAlgorithmProvider, ScriptAlgorithmProvider, ModelerAlgorithmProvider, ProjectProvider