[processing] rename AlgorithmExecutor's runalg() and runalgIterating()

to avoid overlapping with general functions and improve readability
This commit is contained in:
Alexander Bruy 2017-03-22 17:17:14 +02:00
parent 79566f7649
commit c1e6ba0f40
9 changed files with 18 additions and 18 deletions

View File

@ -40,7 +40,7 @@ from qgis.gui import QgsEncodingFileDialog
from processing.core.ProcessingConfig import ProcessingConfig from processing.core.ProcessingConfig import ProcessingConfig
from processing.core.ProcessingLog import ProcessingLog 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.tools import dataobjects
from processing.gui.Postprocessing import handleAlgorithmResults from processing.gui.Postprocessing import handleAlgorithmResults
@ -232,7 +232,7 @@ class FieldsCalculatorDialog(BASE, WIDGET):
ProcessingLog.addToLog(ProcessingLog.LOG_ALGORITHM, ProcessingLog.addToLog(ProcessingLog.LOG_ALGORITHM,
self.alg.getAsCommand()) self.alg.getAsCommand())
self.executed = runalg(self.alg, self.feedback) self.executed = execute(self.alg, self.feedback)
if self.executed: if self.executed:
handleAlgorithmResults(self.alg, handleAlgorithmResults(self.alg,
self.feedback, self.feedback,

View File

@ -49,7 +49,7 @@ from processing.core.ProcessingLog import ProcessingLog
from processing.gui.MessageBarProgress import MessageBarProgress from processing.gui.MessageBarProgress import MessageBarProgress
from processing.gui.RenderingStyles import RenderingStyles from processing.gui.RenderingStyles import RenderingStyles
from processing.gui.Postprocessing import handleAlgorithmResults 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.tools import dataobjects
from processing.core.alglist import algList from processing.core.alglist import algList
@ -298,7 +298,7 @@ class Processing(object):
elif iface is not None: elif iface is not None:
feedback = MessageBarProgress(alg.name) feedback = MessageBarProgress(alg.name)
ret = runalg(alg, feedback) ret = execute(alg, feedback)
if ret: if ret:
if onFinish is not None: if onFinish is not None:
onFinish(alg, feedback) onFinish(alg, feedback)

View File

@ -69,7 +69,7 @@ class ProcessingLog(object):
with codecs.open(ProcessingLog.logFilename(), 'a', with codecs.open(ProcessingLog.logFilename(), 'a',
encoding='utf-8') as logfile: encoding='utf-8') as logfile:
logfile.write(line) logfile.write(line)
algname = msg[len('Processing.runalg("'):] algname = msg[len('processing.runalg("'):]
algname = algname[:algname.index('"')] algname = algname[:algname.index('"')]
if algname not in ProcessingLog.recentAlgs: if algname not in ProcessingLog.recentAlgs:
ProcessingLog.recentAlgs.append(algname) ProcessingLog.recentAlgs.append(algname)

View File

@ -160,7 +160,7 @@ class Parameter(object):
""" """
Returns the value of this parameter as it should have been Returns the value of this parameter as it should have been
entered in the console if calling an algorithm using the entered in the console if calling an algorithm using the
Processing.runalg() method. processing.runalg() method.
""" """
return str(self.value) return str(self.value)

View File

@ -39,7 +39,7 @@ from processing.core.ProcessingConfig import ProcessingConfig
from processing.gui.BatchAlgorithmDialog import BatchAlgorithmDialog from processing.gui.BatchAlgorithmDialog import BatchAlgorithmDialog
from processing.gui.AlgorithmDialogBase import AlgorithmDialogBase 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.gui.Postprocessing import handleAlgorithmResults
from processing.core.parameters import ParameterRaster from processing.core.parameters import ParameterRaster
@ -198,7 +198,7 @@ class AlgorithmDialog(AlgorithmDialogBase):
self.tr('<b>Algorithm {0} starting...</b>').format(self.alg.name)) self.tr('<b>Algorithm {0} starting...</b>').format(self.alg.name))
if self.iterateParam: if self.iterateParam:
if runalgIterating(self.alg, self.iterateParam, self.feedback): if executeIterating(self.alg, self.iterateParam, self.feedback):
self.finish() self.finish()
else: else:
QApplication.restoreOverrideCursor() QApplication.restoreOverrideCursor()
@ -208,7 +208,7 @@ class AlgorithmDialog(AlgorithmDialogBase):
if command: if command:
ProcessingLog.addToLog( ProcessingLog.addToLog(
ProcessingLog.LOG_ALGORITHM, command) ProcessingLog.LOG_ALGORITHM, command)
if runalg(self.alg, self.feedback): if execute(self.alg, self.feedback):
self.finish() self.finish()
else: else:
QApplication.restoreOverrideCursor() QApplication.restoreOverrideCursor()

View File

@ -42,7 +42,7 @@ from processing.tools.system import getTempFilename
from processing.tools import vector from processing.tools import vector
def runalg(alg, feedback=None): def execute(alg, feedback=None):
"""Executes a given algorithm, showing its progress in the """Executes a given algorithm, showing its progress in the
progress object passed along. progress object passed along.
@ -63,7 +63,7 @@ def runalg(alg, feedback=None):
return False return False
def runalgIterating(alg, paramToIter, feedback): def executeIterating(alg, paramToIter, feedback):
# Generate all single-feature layers # Generate all single-feature layers
settings = QgsSettings() settings = QgsSettings()
systemEncoding = settings.value('/UI/encoding', 'System') systemEncoding = settings.value('/UI/encoding', 'System')
@ -96,7 +96,7 @@ def runalgIterating(alg, paramToIter, feedback):
out.value = filename out.value = filename
feedback.setProgressText(tr('Executing iteration {0}/{1}...').format(i, len(filelist))) feedback.setProgressText(tr('Executing iteration {0}/{1}...').format(i, len(filelist)))
feedback.setProgress(i * 100 / len(filelist)) feedback.setProgress(i * 100 / len(filelist))
if runalg(alg, feedback): if execute(alg, feedback):
handleAlgorithmResults(alg, None, False) handleAlgorithmResults(alg, None, False)
else: else:
return False return False

View File

@ -34,7 +34,7 @@ from qgis.gui import QgsMessageBar
from processing.gui.BatchPanel import BatchPanel from processing.gui.BatchPanel import BatchPanel
from processing.gui.AlgorithmDialogBase import AlgorithmDialogBase 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.gui.Postprocessing import handleAlgorithmResults
from processing.core.ProcessingResults import ProcessingResults from processing.core.ProcessingResults import ProcessingResults
@ -121,7 +121,7 @@ class BatchAlgorithmDialog(AlgorithmDialogBase):
for count, alg in enumerate(self.algs): for count, alg in enumerate(self.algs):
self.setText(self.tr('\nProcessing algorithm {0}/{1}...').format(count + 1, len(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)) 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]: if self.load[count]:
handleAlgorithmResults(alg, self.feedback, False) handleAlgorithmResults(alg, self.feedback, False)
self.setInfo(self.tr('Algorithm {0} correctly executed...').format(alg.name)) self.setInfo(self.tr('Algorithm {0} correctly executed...').format(alg.name))

View File

@ -45,7 +45,7 @@ from processing.gui.BatchAlgorithmDialog import BatchAlgorithmDialog
from processing.gui.EditRenderingStylesDialog import EditRenderingStylesDialog from processing.gui.EditRenderingStylesDialog import EditRenderingStylesDialog
from processing.gui.ConfigDialog import ConfigDialog from processing.gui.ConfigDialog import ConfigDialog
from processing.gui.MessageBarProgress import MessageBarProgress from processing.gui.MessageBarProgress import MessageBarProgress
from processing.gui.AlgorithmExecutor import runalg from processing.gui.AlgorithmExecutor import execute
from processing.core.alglist import algList from processing.core.alglist import algList
pluginPath = os.path.split(os.path.dirname(__file__))[0] pluginPath = os.path.split(os.path.dirname(__file__))[0]
@ -275,7 +275,7 @@ class ProcessingToolbox(BASE, WIDGET):
self.addRecentAlgorithms(True) self.addRecentAlgorithms(True)
else: else:
feedback = MessageBarProgress() feedback = MessageBarProgress()
runalg(alg, feedback) execute(alg, feedback)
handleAlgorithmResults(alg, feedback) handleAlgorithmResults(alg, feedback)
feedback.close() feedback.close()
if isinstance(item, TreeActionItem): if isinstance(item, TreeActionItem):

View File

@ -10,7 +10,7 @@ from processing.gui.AlgorithmDialog import AlgorithmDialog
from qgis.utils import iface from qgis.utils import iface
from qgis.core import QgsApplication from qgis.core import QgsApplication
from processing.gui.MessageBarProgress import MessageBarProgress 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.gui.Postprocessing import handleAlgorithmResults
from processing.core.Processing import Processing from processing.core.Processing import Processing
@ -221,7 +221,7 @@ def _executeAlgorithm(alg):
canvas.setMapTool(prevMapTool) canvas.setMapTool(prevMapTool)
else: else:
feedback = MessageBarProgress() feedback = MessageBarProgress()
runalg(alg, feedback) execute(alg, feedback)
handleAlgorithmResults(alg, feedback) handleAlgorithmResults(alg, feedback)
feedback.close() feedback.close()