Skip to content

Commit 322da8b

Browse files
committedMay 25, 2016
Merge pull request #3105 from volaya/processing_cleanup
[processing] cleanup and improvements
2 parents d19767d + 997a368 commit 322da8b

38 files changed

+376
-704
lines changed
 

‎python/plugins/processing/ProcessingPlugin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
from processing.modeler.ModelerDialog import ModelerDialog
4444
from processing.tools.system import tempFolder
4545
from processing.gui.menus import removeMenus, initializeMenus, createMenus
46+
from processing.core.alglist import algList
4647

4748

4849
cmd_folder = os.path.split(inspect.getfile(inspect.currentframe()))[0]
@@ -54,10 +55,9 @@ class ProcessingPlugin:
5455

5556
def __init__(self, iface):
5657
self.iface = iface
57-
58-
def initGui(self):
5958
Processing.initialize()
6059

60+
def initGui(self):
6161
self.commander = None
6262
self.toolbox = ProcessingToolbox()
6363
self.iface.addDockWidget(Qt.RightDockWidgetArea, self.toolbox)
@@ -160,7 +160,7 @@ def openModeler(self):
160160
dlg = ModelerDialog()
161161
dlg.exec_()
162162
if dlg.update:
163-
self.toolbox.updateProvider('model')
163+
algList.reloadProvider('model')
164164

165165
def openResults(self):
166166
dlg = ResultsDialog()
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
***************************************************************************
5+
__init__.py
6+
---------------------
7+
Date : May 2016
8+
Copyright : (C) 2016 by Victor Olaya
9+
Email : volayaf at gmail dot com
10+
***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************
18+
"""
19+
20+
__author__ = 'Victor Olaya'
21+
__date__ = 'May 2016'
22+
__copyright__ = '(C) 2016, Victor Olaya'
23+
24+
# This will get replaced with a git SHA1 when you do a git archive
25+
26+
__revision__ = '$Format:%H$'
27+
28+
import os
29+
30+
from processing.core.Processing import Processing
31+
32+
class ProcessingExampleScriptsPlugin:
33+
34+
def initGui(self):
35+
Processing.addScripts(os.path.join(os.path.dirname(__file__), "scripts"))
36+
37+
def unload(self):
38+
Processing.removeScripts(os.path.join(os.path.dirname(__file__), "scripts"))
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
***************************************************************************
5+
__init__.py
6+
---------------------
7+
Date : July 2013
8+
Copyright : (C) 2013 by Victor Olaya
9+
Email : volayaf at gmail dot com
10+
***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************
18+
"""
19+
from .ProcessingExampleScriptsPlugin import ProcessingExampleScriptsPlugin
20+
21+
__author__ = 'Victor Olaya'
22+
__date__ = 'July 2013'
23+
__copyright__ = '(C) 2013, Victor Olaya'
24+
25+
# This will get replaced with a git SHA1 when you do a git archive
26+
27+
__revision__ = '$Format:%H$'
28+
29+
30+
def classFactory(iface):
31+
return ProcessingExampleScriptsPlugin()
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[general]
2+
name=Processing Example Scripts
3+
description=An example plugin that adds algorithms to Processing as plugins
4+
category=Analysis
5+
version=1.0
6+
qgisMinimumVersion=2.0
7+
8+
author=Victor Olaya
9+
email=volayaf@gmail.com
10+
11+
tags=analysis,processing
12+
13+
homepage=
14+
tracker=
15+
repository=
16+
17+
experimental=False
18+
deprecated=False
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
##text=string
2+
3+
print text

‎python/plugins/processing/algs/grass/GrassUtils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ def grassPath():
106106
if not os.path.isdir(folder):
107107
folder = '/Applications/GRASS-6.4.app/Contents/MacOS'
108108

109+
if folder:
110+
ProcessingConfig.setSettingValue(GrassUtils.GRASS_FOLDER, folder)
109111
return folder or ''
110112

111113
@staticmethod

‎python/plugins/processing/algs/qgis/QGISAlgorithmProvider.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ def __init__(self):
222222
from .ExecuteSQL import ExecuteSQL
223223
self.alglist.extend([ExecuteSQL()])
224224

225+
self.externalAlgs = [] #to store algs added by 3rd party plugins as scripts
226+
225227
folder = os.path.join(os.path.dirname(__file__), 'scripts')
226228
scripts = ScriptUtils.loadFromFolder(folder)
227229
for script in scripts:
@@ -246,7 +248,7 @@ def getIcon(self):
246248
return self._icon
247249

248250
def _loadAlgorithms(self):
249-
self.algs = self.alglist
251+
self.algs = list(self.alglist) + self.externalAlgs
250252

251253
def supportsNonFileBasedOutput(self):
252254
return True

‎python/plugins/processing/core/GeoAlgorithm.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,12 @@ def getAsCommand(self):
541541
s = s[:-1] + ')'
542542
return s
543543

544+
def displayName(self):
545+
return self.i18n_name or self.name
546+
547+
def displayNames(self):
548+
return self.name, self.i18n_name
549+
544550
def tr(self, string, context=''):
545551
if context == '':
546552
context = self.__class__.__name__

0 commit comments

Comments
 (0)
Please sign in to comment.