|
31 | 31 | from processing.core.AlgorithmProvider import AlgorithmProvider |
32 | 32 | from processing.core.ProcessingConfig import ProcessingConfig, Setting |
33 | 33 | 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 |
39 | 34 | from processing.tools.system import isWindows, isMac |
40 | 35 |
|
| 36 | +from .SagaAlgorithm import SagaAlgorithm |
| 37 | +from .SplitRGBBands import SplitRGBBands |
| 38 | +from . import SagaUtils |
41 | 39 |
|
42 | 40 | pluginPath = os.path.normpath(os.path.join( |
43 | 41 | os.path.split(os.path.dirname(__file__))[0], os.pardir)) |
44 | 42 |
|
45 | 43 |
|
46 | 44 | class SagaAlgorithmProvider(AlgorithmProvider): |
47 | 45 |
|
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 | | - |
56 | 46 | def __init__(self): |
57 | 47 | super().__init__() |
58 | 48 | self.activate = True |
@@ -91,34 +81,28 @@ def _loadAlgorithms(self): |
91 | 81 | ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, |
92 | 82 | self.tr('Problem with SAGA installation: SAGA was not found or is not correctly installed')) |
93 | 83 | 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 |
102 | 89 |
|
103 | 90 | folder = SagaUtils.sagaDescriptionPath() |
104 | | - folder = os.path.join(folder, self.supportedVersions[version][0]) |
105 | 91 | for descriptionFile in os.listdir(folder): |
106 | 92 | if descriptionFile.endswith('txt'): |
107 | 93 | 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)))) |
110 | 104 |
|
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()) |
122 | 106 |
|
123 | 107 | def name(self): |
124 | 108 | version = SagaUtils.getInstalledVersion() |
|
0 commit comments