Skip to content

Commit c0eb997

Browse files
authored
Merge pull request #4118 from alexbruy/processing-saga-ltr
[processing] support only SAGA LTR
2 parents a46afca + 732b501 commit c0eb997

File tree

1,435 files changed

+25
-10915
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,435 files changed

+25
-10915
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
11
FILE(GLOB PY_FILES *.py)
2-
FILE(GLOB DESCR212_FILES description/2.1.2/*.txt)
3-
FILE(GLOB DESCR213_FILES description/2.1.3/*.txt)
4-
FILE(GLOB DESCR214_FILES description/2.1.4/*.txt)
5-
FILE(GLOB DESCR220_FILES description/2.2.0/*.txt)
6-
FILE(GLOB DESCR222_FILES description/2.2.2/*.txt)
7-
FILE(GLOB DESCR223_FILES description/2.2.3/*.txt)
8-
FILE(GLOB HELP_FILES help/*.rst)
2+
FILE(GLOB DESCR_FILES description/*.txt)
93

104
ADD_SUBDIRECTORY(ext)
115

126
PLUGIN_INSTALL(processing algs/saga ${PY_FILES})
13-
PLUGIN_INSTALL(processing algs/saga/description/2.1.2 ${DESCR212_FILES})
14-
PLUGIN_INSTALL(processing algs/saga/description/2.1.3 ${DESCR213_FILES})
15-
PLUGIN_INSTALL(processing algs/saga/description/2.1.4 ${DESCR214_FILES})
16-
PLUGIN_INSTALL(processing algs/saga/description/2.2.0 ${DESCR220_FILES})
17-
PLUGIN_INSTALL(processing algs/saga/description/2.2.2 ${DESCR222_FILES})
18-
PLUGIN_INSTALL(processing algs/saga/description/2.2.3 ${DESCR223_FILES})
19-
PLUGIN_INSTALL(processing algs/saga/help ${HELP_FILES})
7+
PLUGIN_INSTALL(processing algs/saga/description/ ${DESCR_FILES})

python/plugins/processing/algs/saga/SagaAlgorithm212.py renamed to python/plugins/processing/algs/saga/SagaAlgorithm.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
sessionExportedLayers = {}
6363

6464

65-
class SagaAlgorithm212(GeoAlgorithm):
65+
class SagaAlgorithm(GeoAlgorithm):
6666

6767
OUTPUT_EXTENT = 'OUTPUT_EXTENT'
6868

python/plugins/processing/algs/saga/SagaAlgorithm213.py

-214
This file was deleted.

python/plugins/processing/algs/saga/SagaAlgorithm214.py

-64
This file was deleted.

python/plugins/processing/algs/saga/SagaAlgorithmProvider.py

+19-35
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,18 @@
3131
from processing.core.AlgorithmProvider import AlgorithmProvider
3232
from processing.core.ProcessingConfig import ProcessingConfig, Setting
3333
from processing.core.ProcessingLog import ProcessingLog
34-
from .SagaAlgorithm212 import SagaAlgorithm212
35-
from .SagaAlgorithm213 import SagaAlgorithm213
36-
from .SagaAlgorithm214 import SagaAlgorithm214
37-
from .SplitRGBBands import SplitRGBBands
38-
from . import SagaUtils
3934
from processing.tools.system import isWindows, isMac
4035

36+
from .SagaAlgorithm import SagaAlgorithm
37+
from .SplitRGBBands import SplitRGBBands
38+
from . import SagaUtils
4139

4240
pluginPath = os.path.normpath(os.path.join(
4341
os.path.split(os.path.dirname(__file__))[0], os.pardir))
4442

4543

4644
class SagaAlgorithmProvider(AlgorithmProvider):
4745

48-
supportedVersions = {"2.1.2": ("2.1.2", SagaAlgorithm212),
49-
"2.1.3": ("2.1.3", SagaAlgorithm213),
50-
"2.1.4": ("2.1.4", SagaAlgorithm214),
51-
"2.2.0": ("2.2.0", SagaAlgorithm214),
52-
"2.2.1": ("2.2.0", SagaAlgorithm214),
53-
"2.2.2": ("2.2.2", SagaAlgorithm214),
54-
"2.2.3": ("2.2.3", SagaAlgorithm214)}
55-
5646
def __init__(self):
5747
super().__init__()
5848
self.activate = True
@@ -91,34 +81,28 @@ def _loadAlgorithms(self):
9181
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
9282
self.tr('Problem with SAGA installation: SAGA was not found or is not correctly installed'))
9383
return
94-
if version not in self.supportedVersions:
95-
lastVersion = sorted(self.supportedVersions.keys())[-1]
96-
if version > lastVersion:
97-
version = lastVersion
98-
else:
99-
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
100-
self.tr('Problem with SAGA installation: installed SAGA version (%s) is not supported' % version))
101-
return
84+
85+
if version not in ['2.3.0', '2.3.1']:
86+
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
87+
self.tr('Problem with SAGA installation: unsupported SAGA version found.'))
88+
return
10289

10390
folder = SagaUtils.sagaDescriptionPath()
104-
folder = os.path.join(folder, self.supportedVersions[version][0])
10591
for descriptionFile in os.listdir(folder):
10692
if descriptionFile.endswith('txt'):
10793
f = os.path.join(folder, descriptionFile)
108-
self._loadAlgorithm(f, version)
109-
self.algs.append(SplitRGBBands())
94+
try:
95+
alg = SagaAlgorithm(os.path.join(folder, descriptionFile))
96+
if alg.name.strip() != '':
97+
self.algs.append(alg)
98+
else:
99+
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
100+
self.tr('Could not open SAGA algorithm: {}'.format(descriptionFile)))
101+
except Exception as e:
102+
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
103+
self.tr('Could not open SAGA algorithm: {}\n{}'.format(descriptionFile, str(e))))
110104

111-
def _loadAlgorithm(self, descriptionFile, version):
112-
try:
113-
alg = self.supportedVersions[version][1](descriptionFile)
114-
if alg.name.strip() != '':
115-
self.algs.append(alg)
116-
else:
117-
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
118-
self.tr('Could not open SAGA algorithm: %s' % descriptionFile))
119-
except Exception as e:
120-
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
121-
self.tr('Could not open SAGA algorithm: %s\n%s' % (descriptionFile, str(e))))
105+
self.algs.append(SplitRGBBands())
122106

123107
def name(self):
124108
version = SagaUtils.getInstalledVersion()

0 commit comments

Comments
 (0)