Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing][API] rename runalg() and runandload() to improve
readability
  • Loading branch information
alexbruy committed Mar 22, 2017
1 parent e1a0110 commit 1a46ddb
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/grass7/Grass7Utils.py
Expand Up @@ -384,8 +384,8 @@ def checkGrass7IsInstalled(ignorePreviousState=False):
if Grass7Utils.isGrass7Installed:
return
try:
from processing import runalg
result = runalg(
from processing import run
result = run(
'grass7:v.voronoi',
points(),
False,
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/processing/algs/qgis/ConcaveHull.py
Expand Up @@ -68,7 +68,7 @@ def processAlgorithm(self, feedback):

# Delaunay triangulation from input point layer
feedback.setProgressText(self.tr('Creating Delaunay triangles...'))
delone_triangles = processing.runalg("qgis:delaunaytriangulation", layer, None)['OUTPUT']
delone_triangles = processing.run("qgis:delaunaytriangulation", layer, None)['OUTPUT']
delaunay_layer = processing.getObject(delone_triangles)

# Get max edge length from Delaunay triangles
Expand Down Expand Up @@ -107,8 +107,8 @@ def processAlgorithm(self, feedback):

# Dissolve all Delaunay triangles
feedback.setProgressText(self.tr('Dissolving Delaunay triangles...'))
dissolved = processing.runalg("qgis:dissolve", delaunay_layer,
True, None, None)['OUTPUT']
dissolved = processing.run("qgis:dissolve", delaunay_layer,
True, None, None)['OUTPUT']
dissolved_layer = processing.getObject(dissolved)

# Save result
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/core/GeoAlgorithm.py
Expand Up @@ -524,7 +524,7 @@ def getAsCommand(self):
console.
"""

s = 'processing.runalg("' + self.commandLineName() + '",'
s = 'processing.run("' + self.commandLineName() + '",'
for param in self.parameters:
s += param.getValueAsCommandLineParameter() + ','
for out in self.outputs:
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/core/ProcessingLog.py
Expand Up @@ -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.run("'):]
algname = algname[:algname.index('"')]
if algname not in ProcessingLog.recentAlgs:
ProcessingLog.recentAlgs.append(algname)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/core/parameters.py
Expand Up @@ -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.run() method.
"""
return str(self.value)

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/gui/HistoryDialog.py
Expand Up @@ -114,7 +114,7 @@ def executeAlgorithm(self):
if isinstance(item, TreeLogEntryItem):
if item.isAlg:
script = 'import processing\n'
script += item.entry.text.replace('runalg(', 'runandload(')
script += item.entry.text.replace('run(', 'runAndLoadResults(')
exec(script)

def changeText(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/gui/TestTools.py
Expand Up @@ -133,7 +133,7 @@ def parseParameters(command):
def createTest(text):
definition = {}

tokens = list(parseParameters(text[len('processing.runalg('):-1]))
tokens = list(parseParameters(text[len('processing.run('):-1]))
cmdname = tokens[0]
alg = Processing.getAlgorithm(cmdname)

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/modeler/ModelerAlgorithm.py
Expand Up @@ -152,7 +152,7 @@ def _toString(v):
params.append(safeName(self.outputs[out.name].description).lower())
else:
params.append(str(None))
s.append("outputs_%s=processing.runalg('%s', %s)" % (self.name, self.consoleName, ",".join(params)))
s.append("outputs_%s=processing.run('%s', %s)" % (self.name, self.consoleName, ",".join(params)))
return s


Expand Down
Expand Up @@ -5,12 +5,12 @@

import processing

result = processing.runalg("qgis:selectbyattribute",
INPUT_LAYER,
"id2",
0,
"2")
result = processing.run("qgis:selectbyattribute",
INPUT_LAYER,
"id2",
0,
"2")

processing.runalg("qgis:saveselectedfeatures",
result["OUTPUT"],
OUTPUT_LAYER)
processing.run("qgis:saveselectedfeatures",
result["OUTPUT"],
OUTPUT_LAYER)
4 changes: 2 additions & 2 deletions python/plugins/processing/tools/general.py
Expand Up @@ -99,7 +99,7 @@ def algorithmHelp(name):
print('Algorithm "{}" not found.'.format(name))


def runalg(algOrName, *args, **kwargs):
def run(algOrName, *args, **kwargs):
"""Executes given algorithm and returns its outputs as dictionary
object.
"""
Expand All @@ -108,7 +108,7 @@ def runalg(algOrName, *args, **kwargs):
return alg.getOutputValuesAsDictionary()


def runandload(name, *args, **kwargs):
def runAndLoadResults(name, *args, **kwargs):
"""Executes given algorithm and load its results into QGIS project
when possible.
"""
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/tools/help.py
Expand Up @@ -89,7 +89,7 @@ def baseHelpForAlgorithm(alg, folder):
f.write('Console usage\n')
f.write('-------------\n')
f.write('\n::\n\n')
cmd = " processing.runalg('{}', ".format(alg.commandLineName())
cmd = " processing.run('{}', ".format(alg.commandLineName())
for p in alg.parameters:
cmd += '{}, '.format(p.name.lower().strip())

Expand Down

0 comments on commit 1a46ddb

Please sign in to comment.