36
36
from qgis .core import QgsMessageLog
37
37
38
38
import processing
39
- from processing .gui import AlgorithmClassification
40
- from processing .modeler .ModelerUtils import ModelerUtils
39
+ from processing .core .AlgorithmProvider import AlgorithmProvider
41
40
from processing .core .ProcessingConfig import ProcessingConfig
42
41
from processing .core .GeoAlgorithm import GeoAlgorithm
43
42
from processing .core .ProcessingLog import ProcessingLog
44
43
from processing .gui .MessageBarProgress import MessageBarProgress
45
44
from processing .gui .RenderingStyles import RenderingStyles
46
45
from processing .gui .Postprocessing import handleAlgorithmResults
47
46
from processing .gui .AlgorithmExecutor import runalg
48
- from processing .modeler .ModelerAlgorithmProvider import ModelerAlgorithmProvider
49
- from processing .modeler .ModelerOnlyAlgorithmProvider import ModelerOnlyAlgorithmProvider
50
- from processing .algs .qgis .QGISAlgorithmProvider import QGISAlgorithmProvider
51
- from processing .algs .grass .GrassAlgorithmProvider import GrassAlgorithmProvider
52
- from processing .algs .grass7 .Grass7AlgorithmProvider import Grass7AlgorithmProvider
53
- from processing .algs .lidar .LidarToolsAlgorithmProvider import LidarToolsAlgorithmProvider
54
- from processing .algs .gdal .GdalOgrAlgorithmProvider import GdalOgrAlgorithmProvider
55
- from processing .algs .otb .OTBAlgorithmProvider import OTBAlgorithmProvider
56
- from processing .algs .r .RAlgorithmProvider import RAlgorithmProvider
57
- from processing .algs .saga .SagaAlgorithmProvider import SagaAlgorithmProvider
58
- from processing .script .ScriptAlgorithmProvider import ScriptAlgorithmProvider
59
- from processing .algs .taudem .TauDEMAlgorithmProvider import TauDEMAlgorithmProvider
60
- from processing .preconfigured .PreconfiguredAlgorithmProvider import PreconfiguredAlgorithmProvider
61
-
62
47
from processing .tools import dataobjects
63
48
64
49
@@ -85,22 +70,21 @@ class Processing:
85
70
# All the registered context menu actions for the toolbox
86
71
contextMenuActions = []
87
72
88
- modeler = ModelerAlgorithmProvider ()
89
-
90
73
@staticmethod
91
- def addProvider (provider , updateList = True ):
74
+ def addProvider (provider ):
92
75
"""Use this method to add algorithms from external providers.
93
76
"""
94
77
95
- # Note: this might slow down the initialization process if
96
- # there are many new providers added. Should think of a
97
- # different solution
78
+ if provider .getName () in [p .getName for p in Processing .providers ]:
79
+ return
98
80
try :
99
81
provider .initializeSettings ()
100
82
Processing .providers .append (provider )
101
83
ProcessingConfig .readSettings ()
102
- if updateList :
103
- Processing .updateAlgsList ()
84
+ provider .loadAlgorithms ()
85
+ Processing .algs [provider .getName ()] = {a .commandLineName (): a for a in provider .algs }
86
+ Processing .actions [provider .getName ()] = provider .actions
87
+ Processing .contextMenuActions .extend (provider .contextMenuActions )
104
88
algListWatcher .providerAdded .emit (provider .getName ())
105
89
except :
106
90
ProcessingLog .addToLog (
@@ -125,7 +109,7 @@ def removeProvider(provider):
125
109
# This try catch block is here to avoid problems if the
126
110
# plugin with a provider is unloaded after the Processing
127
111
# framework itself has been unloaded. It is a quick fix
128
- # before I found out how to properly avoid that.
112
+ # before I find out how to properly avoid that.
129
113
pass
130
114
131
115
@staticmethod
@@ -139,27 +123,12 @@ def getProviderFromName(name):
139
123
@staticmethod
140
124
def initialize ():
141
125
# Add the basic providers
142
- Processing .addProvider (QGISAlgorithmProvider (), updateList = False )
143
- Processing .addProvider (ModelerOnlyAlgorithmProvider (), updateList = False )
144
- Processing .addProvider (GdalOgrAlgorithmProvider (), updateList = False )
145
- Processing .addProvider (LidarToolsAlgorithmProvider (), updateList = False )
146
- Processing .addProvider (OTBAlgorithmProvider (), updateList = False )
147
- Processing .addProvider (RAlgorithmProvider (), updateList = False )
148
- Processing .addProvider (SagaAlgorithmProvider (), updateList = False )
149
- Processing .addProvider (GrassAlgorithmProvider (), updateList = False )
150
- Processing .addProvider (Grass7AlgorithmProvider (), updateList = False )
151
- Processing .addProvider (ScriptAlgorithmProvider (), updateList = False )
152
- Processing .addProvider (TauDEMAlgorithmProvider (), updateList = False )
153
- Processing .addProvider (PreconfiguredAlgorithmProvider (), updateList = False )
154
- Processing .addProvider (Processing .modeler , updateList = False )
155
- Processing .modeler .initializeSettings ()
156
-
126
+ for c in AlgorithmProvider .__subclasses__ ():
127
+ Processing .addProvider (c ())
157
128
# And initialize
158
- AlgorithmClassification .loadClassification ()
159
129
ProcessingConfig .initialize ()
160
130
ProcessingConfig .readSettings ()
161
131
RenderingStyles .loadStyles ()
162
- Processing .loadFromProviders ()
163
132
164
133
@staticmethod
165
134
def updateAlgsList ():
@@ -168,21 +137,10 @@ def updateAlgsList():
168
137
algorithm providers.
169
138
"""
170
139
QApplication .setOverrideCursor (QCursor (Qt .WaitCursor ))
171
- Processing .loadFromProviders ()
140
+ for p in Processing .providers :
141
+ Processing .reloadProvider (p )
172
142
QApplication .restoreOverrideCursor ()
173
143
174
- @staticmethod
175
- def loadFromProviders ():
176
- Processing .loadAlgorithms ()
177
- Processing .loadActions ()
178
- Processing .loadContextMenuActions ()
179
-
180
- @staticmethod
181
- def updateProviders ():
182
- providers = [p for p in Processing .providers if p .getName () != "model" ]
183
- for provider in providers :
184
- provider .loadAlgorithms ()
185
-
186
144
@staticmethod
187
145
def reloadProvider (providerName ):
188
146
for p in Processing .providers :
@@ -191,50 +149,6 @@ def reloadProvider(providerName):
191
149
Processing .algs [
192
150
p .getName ()] = {a .commandLineName (): a for a in p .algs }
193
151
194
- @staticmethod
195
- def loadAlgorithms ():
196
- Processing .algs = {}
197
- Processing .updateProviders ()
198
- providers = [p for p in Processing .providers if p .getName () != "model" ]
199
- for provider in providers :
200
- providerAlgs = provider .algs
201
- algs = {}
202
- for alg in providerAlgs :
203
- algs [alg .commandLineName ()] = alg
204
- Processing .algs [provider .getName ()] = algs
205
-
206
- provs = {}
207
- for provider in Processing .providers :
208
- provs [provider .getName ()] = provider
209
-
210
- ModelerUtils .allAlgs = Processing .algs
211
- ModelerUtils .providers = provs
212
-
213
- Processing .modeler .loadAlgorithms ()
214
-
215
- algs = {}
216
- for alg in Processing .modeler .algs :
217
- algs [alg .commandLineName ()] = alg
218
- Processing .algs [Processing .modeler .getName ()] = algs
219
-
220
- @staticmethod
221
- def loadActions ():
222
- for provider in Processing .providers :
223
- providerActions = provider .actions
224
- actions = list ()
225
- for action in providerActions :
226
- actions .append (action )
227
- Processing .actions [provider .getName ()] = actions
228
-
229
- Processing .actions [provider .getName ()] = actions
230
-
231
- @staticmethod
232
- def loadContextMenuActions ():
233
- Processing .contextMenuActions = []
234
- for provider in Processing .providers :
235
- providerActions = provider .contextMenuActions
236
- for action in providerActions :
237
- Processing .contextMenuActions .append (action )
238
152
239
153
@staticmethod
240
154
def getAlgorithm (name ):
0 commit comments