First steps in resurrecting script algorithms

This commit is contained in:
Nyall Dawson 2017-06-26 14:49:21 +10:00
parent 60f80f9355
commit f13920bb19
2 changed files with 12 additions and 4 deletions

View File

@ -293,7 +293,7 @@ class QGISAlgorithmProvider(QgsProcessingProvider):
scripts = ScriptUtils.loadFromFolder(folder) scripts = ScriptUtils.loadFromFolder(folder)
for script in scripts: for script in scripts:
script.allowEdit = False script.allowEdit = False
#algs.extend(scripts) algs.extend(scripts)
return algs return algs

View File

@ -35,7 +35,10 @@ from qgis.core import (QgsExpressionContextUtils,
QgsProject, QgsProject,
QgsApplication, QgsApplication,
QgsMessageLog, QgsMessageLog,
QgsProcessingUtils) QgsProcessingUtils,
QgsProcessingAlgorithm)
from qgis.PyQt.QtCore import (QCoreApplication)
from processing.core.GeoAlgorithm import GeoAlgorithm from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.gui.Help2Html import getHtmlFromHelpFile from processing.gui.Help2Html import getHtmlFromHelpFile
@ -46,7 +49,7 @@ from processing.script.WrongScriptException import WrongScriptException
pluginPath = os.path.split(os.path.dirname(__file__))[0] pluginPath = os.path.split(os.path.dirname(__file__))[0]
class ScriptAlgorithm(GeoAlgorithm): class ScriptAlgorithm(QgsProcessingAlgorithm):
def __init__(self, descriptionFile, script=None): def __init__(self, descriptionFile, script=None):
"""The script parameter can be used to directly pass the code """The script parameter can be used to directly pass the code
@ -56,7 +59,7 @@ class ScriptAlgorithm(GeoAlgorithm):
not be used in other cases. not be used in other cases.
""" """
GeoAlgorithm.__init__(self) super().__init__()
self._icon = QgsApplication.getThemeIcon("/processingScript.svg") self._icon = QgsApplication.getThemeIcon("/processingScript.svg")
self._name = '' self._name = ''
self._display_name = '' self._display_name = ''
@ -236,3 +239,8 @@ class ScriptAlgorithm(GeoAlgorithm):
except: except:
return descs return descs
return descs return descs
def tr(self, string, context=''):
if context == '':
context = self.__class__.__name__
return QCoreApplication.translate(context, string)