Skip to content
Permalink
Browse files
[processing] rename AlgorithmExecutor's runalg() and runalgIterating()
to avoid overlapping with general functions and improve readability
  • Loading branch information
alexbruy committed Mar 22, 2017
1 parent 79566f7 commit c1e6ba0f4031118388c1cb9bb40dfdd3fc28d468
@@ -40,7 +40,7 @@

from processing.core.ProcessingConfig import ProcessingConfig
from processing.core.ProcessingLog import ProcessingLog
from processing.gui.AlgorithmExecutor import runalg
from processing.gui.AlgorithmExecutor import execute
from processing.tools import dataobjects
from processing.gui.Postprocessing import handleAlgorithmResults

@@ -232,7 +232,7 @@ def accept(self):
ProcessingLog.addToLog(ProcessingLog.LOG_ALGORITHM,
self.alg.getAsCommand())

self.executed = runalg(self.alg, self.feedback)
self.executed = execute(self.alg, self.feedback)
if self.executed:
handleAlgorithmResults(self.alg,
self.feedback,
@@ -49,7 +49,7 @@
from processing.gui.MessageBarProgress import MessageBarProgress
from processing.gui.RenderingStyles import RenderingStyles
from processing.gui.Postprocessing import handleAlgorithmResults
from processing.gui.AlgorithmExecutor import runalg
from processing.gui.AlgorithmExecutor import execute
from processing.tools import dataobjects
from processing.core.alglist import algList

@@ -298,7 +298,7 @@ def runAlgorithm(algOrName, onFinish, *args, **kwargs):
elif iface is not None:
feedback = MessageBarProgress(alg.name)

ret = runalg(alg, feedback)
ret = execute(alg, feedback)
if ret:
if onFinish is not None:
onFinish(alg, feedback)
@@ -69,7 +69,7 @@ def addToLog(msgtype, msg):
with codecs.open(ProcessingLog.logFilename(), 'a',
encoding='utf-8') as logfile:
logfile.write(line)
algname = msg[len('Processing.runalg("'):]
algname = msg[len('processing.runalg("'):]
algname = algname[:algname.index('"')]
if algname not in ProcessingLog.recentAlgs:
ProcessingLog.recentAlgs.append(algname)
@@ -160,7 +160,7 @@ def getValueAsCommandLineParameter(self):
"""
Returns the value of this parameter as it should have been
entered in the console if calling an algorithm using the
Processing.runalg() method.
processing.runalg() method.
"""
return str(self.value)

@@ -39,7 +39,7 @@

from processing.gui.BatchAlgorithmDialog import BatchAlgorithmDialog
from processing.gui.AlgorithmDialogBase import AlgorithmDialogBase
from processing.gui.AlgorithmExecutor import runalg, runalgIterating
from processing.gui.AlgorithmExecutor import execute, executeIterating
from processing.gui.Postprocessing import handleAlgorithmResults

from processing.core.parameters import ParameterRaster
@@ -198,7 +198,7 @@ def accept(self):
self.tr('<b>Algorithm {0} starting...</b>').format(self.alg.name))

if self.iterateParam:
if runalgIterating(self.alg, self.iterateParam, self.feedback):
if executeIterating(self.alg, self.iterateParam, self.feedback):
self.finish()
else:
QApplication.restoreOverrideCursor()
@@ -208,7 +208,7 @@ def accept(self):
if command:
ProcessingLog.addToLog(
ProcessingLog.LOG_ALGORITHM, command)
if runalg(self.alg, self.feedback):
if execute(self.alg, self.feedback):
self.finish()
else:
QApplication.restoreOverrideCursor()
@@ -42,7 +42,7 @@
from processing.tools import vector


def runalg(alg, feedback=None):
def execute(alg, feedback=None):
"""Executes a given algorithm, showing its progress in the
progress object passed along.
@@ -63,7 +63,7 @@ def runalg(alg, feedback=None):
return False


def runalgIterating(alg, paramToIter, feedback):
def executeIterating(alg, paramToIter, feedback):
# Generate all single-feature layers
settings = QgsSettings()
systemEncoding = settings.value('/UI/encoding', 'System')
@@ -96,7 +96,7 @@ def runalgIterating(alg, paramToIter, feedback):
out.value = filename
feedback.setProgressText(tr('Executing iteration {0}/{1}...').format(i, len(filelist)))
feedback.setProgress(i * 100 / len(filelist))
if runalg(alg, feedback):
if execute(alg, feedback):
handleAlgorithmResults(alg, None, False)
else:
return False
@@ -34,7 +34,7 @@

from processing.gui.BatchPanel import BatchPanel
from processing.gui.AlgorithmDialogBase import AlgorithmDialogBase
from processing.gui.AlgorithmExecutor import runalg
from processing.gui.AlgorithmExecutor import execute
from processing.gui.Postprocessing import handleAlgorithmResults

from processing.core.ProcessingResults import ProcessingResults
@@ -121,7 +121,7 @@ def accept(self):
for count, alg in enumerate(self.algs):
self.setText(self.tr('\nProcessing algorithm {0}/{1}...').format(count + 1, len(self.algs)))
self.setInfo(self.tr('<b>Algorithm {0} starting...</b>').format(alg.name))
if runalg(alg, self.feedback) and not self.canceled:
if execute(alg, self.feedback) and not self.canceled:
if self.load[count]:
handleAlgorithmResults(alg, self.feedback, False)
self.setInfo(self.tr('Algorithm {0} correctly executed...').format(alg.name))
@@ -45,7 +45,7 @@
from processing.gui.EditRenderingStylesDialog import EditRenderingStylesDialog
from processing.gui.ConfigDialog import ConfigDialog
from processing.gui.MessageBarProgress import MessageBarProgress
from processing.gui.AlgorithmExecutor import runalg
from processing.gui.AlgorithmExecutor import execute
from processing.core.alglist import algList

pluginPath = os.path.split(os.path.dirname(__file__))[0]
@@ -275,7 +275,7 @@ def executeAlgorithm(self):
self.addRecentAlgorithms(True)
else:
feedback = MessageBarProgress()
runalg(alg, feedback)
execute(alg, feedback)
handleAlgorithmResults(alg, feedback)
feedback.close()
if isinstance(item, TreeActionItem):
@@ -10,7 +10,7 @@
from qgis.utils import iface
from qgis.core import QgsApplication
from processing.gui.MessageBarProgress import MessageBarProgress
from processing.gui.AlgorithmExecutor import runalg
from processing.gui.AlgorithmExecutor import execute
from processing.gui.Postprocessing import handleAlgorithmResults
from processing.core.Processing import Processing

@@ -221,7 +221,7 @@ def _executeAlgorithm(alg):
canvas.setMapTool(prevMapTool)
else:
feedback = MessageBarProgress()
runalg(alg, feedback)
execute(alg, feedback)
handleAlgorithmResults(alg, feedback)
feedback.close()

0 comments on commit c1e6ba0

Please sign in to comment.