Skip to content
Permalink
Browse files
Merge pull request #1490 from radosuav/small_processing_fixes2
[processing] Small fixes 2
  • Loading branch information
volaya committed Jun 28, 2014
2 parents 09645e4 + 2982b57 commit 5c9cb5a0cd3d34916c21e09bca2ec008ddeb2ece
@@ -138,7 +138,7 @@ def getFormatShortNameFromFilename(filename):
def escapeAndJoin(strList):
joined = ''
for s in strList:
if ' ' in s:
if s[0]!='-' and ' ' in s:
escaped = '"' + s.replace('\\', '\\\\').replace('"', '\\"') \
+ '"'
else:
@@ -361,17 +361,10 @@ def setOutputCRS(self):
if layer.source() == inputlayer:
self.crs = layer.crs()
return
if isinstance(param, ParameterRaster) \
or isinstance(param, ParameterMultipleInput) \
and param.datatype \
== ParameterMultipleInput.TYPE_RASTER:
p = QgsProviderRegistry.instance().provider('gdal',
inputlayer)
else:
p = QgsProviderRegistry.instance().provider('ogr',
inputlayer)
p = dataobjects.getObjectFromUri(inputlayer)
if p is not None:
self.crs = p.crs()
p = None
return
try:
from qgis.utils import iface
@@ -286,24 +286,39 @@ def runAlgorithm(algOrName, onFinish, *args):
if alg is None:
print 'Error: Algorithm not found\n'
return
if len(args) != alg.getVisibleParametersCount() \
+ alg.getVisibleOutputsCount():
print 'Error: Wrong number of parameters'
processing.alghelp(algOrName)
return

alg = alg.getCopy()
if isinstance(args, dict):
# Set params by name
for (name, value) in args.items():
if alg.getParameterFromName(name).setValue(value):

if len(args) == 1 and isinstance(args[0], dict):
# Set params by name and try to run the alg even if not all parameter values are provided,
# by using the default values instead.
setParams = []
for (name, value) in args[0].items():
param = alg.getParameterFromName(name)
if param and param.setValue(value):
setParams.append(name)
continue
if alg.getOutputFromName(name).setValue(value):
output = alg.getOutputFromName(name)
if output and output.setValue(value):
continue
print 'Error: Wrong parameter value %s for parameter %s.' \
% (value, name)
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, "Error in %s. Wrong parameter value %s for parameter %s." \
% (alg.name, value, name))
return
# fill any missing parameters with default values if allowed
for param in alg.parameters:
if param.name not in setParams:
if not param.setValue(None):
print ("Error: Missing parameter value for parameter %s." % (param.name))
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, "Error in %s. Missing parameter value for parameter %s." \
% (alg.name, param.name))
return
else:
if len(args) != alg.getVisibleParametersCount() \
+ alg.getVisibleOutputsCount():
print 'Error: Wrong number of parameters'
processing.alghelp(algOrName)
return
i = 0
for param in alg.parameters:
if not param.hidden:
@@ -63,7 +63,7 @@ def showSelectionDialog(self):
path = ''

filename = QtGui.QFileDialog.getOpenFileName(self, self.param.description, path,
self.param.getFileFilter())
'All files(*.*);;' + self.param.getFileFilter())
if filename:
self.text.addItem(filename, filename)
self.text.setCurrentIndex(self.text.count() - 1)
@@ -123,6 +123,10 @@ def updateProvider(self, providerName, updateAlgsList = True):
if isinstance(child, TreeProviderItem):
if child.providerName == providerName:
child.refresh()
# sort categories and items in categories
child.sortChildren(0, Qt.AscendingOrder)
for i in xrange(child.childCount()):
child.child(i).sortChildren(0, Qt.AscendingOrder)
break

def showPopupMenu(self, point):

0 comments on commit 5c9cb5a

Please sign in to comment.