Skip to content

Commit

Permalink
Merge pull request #3105 from volaya/processing_cleanup
Browse files Browse the repository at this point in the history
[processing] cleanup and improvements
  • Loading branch information
alexbruy committed May 25, 2016
2 parents d19767d + 997a368 commit 322da8b
Show file tree
Hide file tree
Showing 38 changed files with 376 additions and 704 deletions.
6 changes: 3 additions & 3 deletions python/plugins/processing/ProcessingPlugin.py
Expand Up @@ -43,6 +43,7 @@
from processing.modeler.ModelerDialog import ModelerDialog from processing.modeler.ModelerDialog import ModelerDialog
from processing.tools.system import tempFolder from processing.tools.system import tempFolder
from processing.gui.menus import removeMenus, initializeMenus, createMenus from processing.gui.menus import removeMenus, initializeMenus, createMenus
from processing.core.alglist import algList




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


def __init__(self, iface): def __init__(self, iface):
self.iface = iface self.iface = iface

def initGui(self):
Processing.initialize() Processing.initialize()


def initGui(self):
self.commander = None self.commander = None
self.toolbox = ProcessingToolbox() self.toolbox = ProcessingToolbox()
self.iface.addDockWidget(Qt.RightDockWidgetArea, self.toolbox) self.iface.addDockWidget(Qt.RightDockWidgetArea, self.toolbox)
Expand Down Expand Up @@ -160,7 +160,7 @@ def openModeler(self):
dlg = ModelerDialog() dlg = ModelerDialog()
dlg.exec_() dlg.exec_()
if dlg.update: if dlg.update:
self.toolbox.updateProvider('model') algList.reloadProvider('model')


def openResults(self): def openResults(self):
dlg = ResultsDialog() dlg = ResultsDialog()
Expand Down
@@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
__init__.py
---------------------
Date : May 2016
Copyright : (C) 2016 by Victor Olaya
Email : volayaf 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__ = 'Victor Olaya'
__date__ = 'May 2016'
__copyright__ = '(C) 2016, Victor Olaya'

# This will get replaced with a git SHA1 when you do a git archive

__revision__ = '$Format:%H$'

import os

from processing.core.Processing import Processing

class ProcessingExampleScriptsPlugin:

def initGui(self):
Processing.addScripts(os.path.join(os.path.dirname(__file__), "scripts"))

def unload(self):
Processing.removeScripts(os.path.join(os.path.dirname(__file__), "scripts"))
31 changes: 31 additions & 0 deletions python/plugins/processing/algs/examplescripts/__init__.py
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
__init__.py
---------------------
Date : July 2013
Copyright : (C) 2013 by Victor Olaya
Email : volayaf 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. *
* *
***************************************************************************
"""
from .ProcessingExampleScriptsPlugin import ProcessingExampleScriptsPlugin

__author__ = 'Victor Olaya'
__date__ = 'July 2013'
__copyright__ = '(C) 2013, Victor Olaya'

# This will get replaced with a git SHA1 when you do a git archive

__revision__ = '$Format:%H$'


def classFactory(iface):
return ProcessingExampleScriptsPlugin()
18 changes: 18 additions & 0 deletions python/plugins/processing/algs/examplescripts/metadata.txt
@@ -0,0 +1,18 @@
[general]
name=Processing Example Scripts
description=An example plugin that adds algorithms to Processing as plugins
category=Analysis
version=1.0
qgisMinimumVersion=2.0

author=Victor Olaya
email=volayaf@gmail.com

tags=analysis,processing

homepage=
tracker=
repository=

experimental=False
deprecated=False
@@ -0,0 +1,3 @@
##text=string

print text
2 changes: 2 additions & 0 deletions python/plugins/processing/algs/grass/GrassUtils.py
Expand Up @@ -106,6 +106,8 @@ def grassPath():
if not os.path.isdir(folder): if not os.path.isdir(folder):
folder = '/Applications/GRASS-6.4.app/Contents/MacOS' folder = '/Applications/GRASS-6.4.app/Contents/MacOS'


if folder:
ProcessingConfig.setSettingValue(GrassUtils.GRASS_FOLDER, folder)
return folder or '' return folder or ''


@staticmethod @staticmethod
Expand Down
4 changes: 3 additions & 1 deletion python/plugins/processing/algs/qgis/QGISAlgorithmProvider.py
Expand Up @@ -222,6 +222,8 @@ def __init__(self):
from .ExecuteSQL import ExecuteSQL from .ExecuteSQL import ExecuteSQL
self.alglist.extend([ExecuteSQL()]) self.alglist.extend([ExecuteSQL()])


self.externalAlgs = [] #to store algs added by 3rd party plugins as scripts

folder = os.path.join(os.path.dirname(__file__), 'scripts') folder = os.path.join(os.path.dirname(__file__), 'scripts')
scripts = ScriptUtils.loadFromFolder(folder) scripts = ScriptUtils.loadFromFolder(folder)
for script in scripts: for script in scripts:
Expand All @@ -246,7 +248,7 @@ def getIcon(self):
return self._icon return self._icon


def _loadAlgorithms(self): def _loadAlgorithms(self):
self.algs = self.alglist self.algs = list(self.alglist) + self.externalAlgs


def supportsNonFileBasedOutput(self): def supportsNonFileBasedOutput(self):
return True return True
6 changes: 6 additions & 0 deletions python/plugins/processing/core/GeoAlgorithm.py
Expand Up @@ -541,6 +541,12 @@ def getAsCommand(self):
s = s[:-1] + ')' s = s[:-1] + ')'
return s return s


def displayName(self):
return self.i18n_name or self.name

def displayNames(self):
return self.name, self.i18n_name

def tr(self, string, context=''): def tr(self, string, context=''):
if context == '': if context == '':
context = self.__class__.__name__ context = self.__class__.__name__
Expand Down

0 comments on commit 322da8b

Please sign in to comment.