4 changes: 2 additions & 2 deletions python/plugins/sextante/algs/ftools/PointsInPolygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ def processAlgorithm(self, progress):

outFeat.setGeometry(geom)
if idxCount == len(attrs):
attrs.append(QVariant(count))
attrs.append(count)
else:
attrs[idxCount] = QVariant(count)
attrs[idxCount] = count
outFeat.setAttributes(attrs)
writer.addFeature(outFeat)

Expand Down
6 changes: 3 additions & 3 deletions python/plugins/sextante/algs/ftools/PointsInPolygonUnique.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ def processAlgorithm(self, progress):
ftPoint = pointLayer.getFeatures(request).next()
tmpGeom = QgsGeometry(ftPoint.geometry())
if geom.contains(tmpGeom):
clazz = ftPoint.attributes()[classFieldIndex].toString()
clazz = ftPoint.attributes()[classFieldIndex]
if not clazz in classes:
classes.append(clazz)

outFeat.setGeometry(geom)
if idxCount == len(attrs):
attrs.append(QVariant(len(classes)))
attrs.append(len(classes))
else:
attrs[idxCount] = QVariant(len(classes))
attrs[idxCount] = len(classes)
outFeat.setAttributes(attrs)
writer.addFeature(outFeat)

Expand Down
12 changes: 7 additions & 5 deletions python/plugins/sextante/algs/ftools/PointsInPolygonWeighted.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,17 @@ def processAlgorithm(self, progress):
ftPoint = pointLayer.getFeatures(request).next()
tmpGeom = QgsGeometry(ftPoint.geometry())
if geom.contains(tmpGeom):
weight, ok = ftPoint.attributes()[fieldIdx].toDouble()
if ok:
count += weight
weight = str(ftPoint.attributes()[fieldIdx])
try:
count += float(weight)
except:
pass #ignore fields with non-numeric values

outFeat.setGeometry(geom)
if idxCount == len(attrs):
attrs.append(QVariant(count))
attrs.append(count)
else:
attrs[idxCount] = QVariant(count)
attrs[idxCount] = count
outFeat.setAttributes(attrs)
writer.addFeature(outFeat)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def processAlgorithm(self, progress):
FIDs= []
for inFeat in features:
attrs = inFeat.attributes()
if attrs[index] == QVariant(i):
if attrs[index] == i:
FIDs.append(inFeat.id())
current += 1
progress.setPercentage(int(current * total))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def processAlgorithm(self, progress):
for inFeat in features:
atMap = inFeat.attributes()
idVar = atMap[index]
if idVar.toString().trimmed() == i.toString().trimmed():
if idVar.strip() == i.strip():
if first:
attrs = atMap
print attrs
Expand Down
8 changes: 4 additions & 4 deletions python/plugins/sextante/algs/ftools/SumLines.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ def processAlgorithm(self, progress):

outFeat.setGeometry(inGeom)
if idxLength == len(attrs):
attrs.append(QVariant(length))
attrs.append(length)
else:
attrs[idxLength] = QVariant(length)
attrs[idxLength] = length
if idxCount == len(attrs):
attrs.append(QVariant(count))
attrs.append(count)
else:
attrs[idxCount] = QVariant(count)
attrs[idxCount] = count
outFeat.setAttributes(attrs)
writer.addFeature(outFeat)

Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/algs/ftools/UniqueValues.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def processAlgorithm(self, progress):
values = utils.getUniqueValues(layer, layer.fieldNameIndex(fieldName))
self.createHTML(outputFile, values)
self.setOutputValue(self.TOTAL_VALUES, len(values))
self.setOutputValue(self.UNIQUE_VALUES, ";".join([unicode(v.toString()) for v in values]))
self.setOutputValue(self.UNIQUE_VALUES, ";".join([unicode(v) for v in values]))

def createHTML(self, outputFile, algData):
f = codecs.open(outputFile, "w", encoding="utf-8")
Expand All @@ -76,6 +76,6 @@ def createHTML(self, outputFile, algData):
f.write("<p>Unique values:</p>")
f.write("<ul>")
for s in algData:
f.write("<li>" + unicode(s.toString()) + "</li>")
f.write("<li>" + unicode(s) + "</li>")
f.write("</ul></body></html>")
f.close()
32 changes: 16 additions & 16 deletions python/plugins/sextante/algs/mmqgisx/MMQGISXAlgorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ def processAlgorithm(self, progress):
y = y + vspacing;

feature.setGeometry(geometry.fromPolyline(polyline))
feature.setAttributes([QVariant(x), QVariant(0)])
feature.setAttributes([x, 0])
out.addFeature(feature)
linecount = linecount + 1
#self.iface.mainWindow().statusBar().showMessage("Line " + str(linecount) + " " + str(x))
Expand All @@ -463,7 +463,7 @@ def processAlgorithm(self, progress):
x = x + hspacing;

feature.setGeometry(geometry.fromPolyline(polyline))
feature.setAttributes([QVariant(0), QVariant(y)])
feature.setAttributes([0, y])
out.addFeature(feature)
linecount = linecount + 1
#self.iface.mainWindow().statusBar().showMessage("Line " + str(linecount) + " " + str(y))
Expand All @@ -483,7 +483,7 @@ def processAlgorithm(self, progress):
geometry = QgsGeometry()
feature = QgsFeature()
feature.setGeometry(geometry.fromPolygon([polyline]))
feature.setAttributes([QVariant(x + (hspacing / 2.0)), QVariant(y + (vspacing / 2.0))])
feature.setAttributes([x + (hspacing / 2.0), y + (vspacing / 2.0)])
out.addFeature(feature)
linecount = linecount + 1
y = y + vspacing;
Expand All @@ -509,7 +509,7 @@ def processAlgorithm(self, progress):
geometry = QgsGeometry()
feature = QgsFeature()
feature.setGeometry(geometry.fromPolygon([polyline]))
feature.setAttributes([QVariant(x + (hspacing / 2.0)), QVariant(y + (vspacing / 2.0))])
feature.setAttributes([x + (hspacing / 2.0), y + (vspacing / 2.0)])
out.addFeature(feature)
linecount = linecount + 1
y = y + vspacing;
Expand Down Expand Up @@ -547,7 +547,7 @@ def processAlgorithm(self, progress):
geometry = QgsGeometry()
feature = QgsFeature()
feature.setGeometry(geometry.fromPolygon([polyline]))
feature.setAttributes([QVariant(x), QVariant(y)])
feature.setAttributes([x, y])
out.addFeature(feature)
linecount = linecount + 1
y = y + vspacing;
Expand Down Expand Up @@ -800,7 +800,7 @@ def processAlgorithm(self, progress):
features = QGisLayers.features(layerdest)
for feature in features:
hubs.append(mmqgisx_hub(feature.geometry().boundingBox().center(), \
feature.attributes()[nameindex].toString()))
unicode(feature.attributes()[nameindex])))

# Scan source points, find nearest hub, and write to output file
writecount = 0
Expand All @@ -823,7 +823,7 @@ def processAlgorithm(self, progress):
hubdist = thisdist

attributes = feature.attributes()
attributes.append(QVariant(closest.name))
attributes.append(closest.name)
if units == "Feet":
hubdist = hubdist * 3.2808399
elif units == "Miles":
Expand All @@ -832,7 +832,7 @@ def processAlgorithm(self, progress):
hubdist = hubdist / 1000
elif units != "Meters":
hubdist = sqrt(pow(source.x() - closest.point.x(), 2.0) + pow(source.y() - closest.point.y(), 2.0))
attributes.append(QVariant(hubdist))
attributes.append(hubdist)

outfeature = QgsFeature()
outfeature.setAttributes(attributes)
Expand Down Expand Up @@ -906,12 +906,12 @@ def processAlgorithm(self, progress):
i += 1
spokex = spokepoint.geometry().boundingBox().center().x()
spokey = spokepoint.geometry().boundingBox().center().y()
spokeid = unicode(spokepoint.attributes()[spokeindex].toString())
spokeid = unicode(spokepoint.attributes()[spokeindex])
progress.setPercentage(float(i) / len(spokepoints) * 100)
# Scan hub points to find first matching hub
hubpoints = QGisLayers.features(hublayer)
for hubpoint in hubpoints:
hubid = unicode(hubpoint.attributes()[hubindex].toString())
hubid = unicode(hubpoint.attributes()[hubindex])
if hubid == spokeid:
hubx = hubpoint.geometry().boundingBox().center().x()
huby = hubpoint.geometry().boundingBox().center().y()
Expand Down Expand Up @@ -1005,7 +1005,7 @@ def processAlgorithm(self, progress):
if (dfield in idx):
dattributes.append(sattributes[idx[dfield]])
else:
dattributes.append(QVariant(dfield.type()))
dattributes.append(dfield.type())
feature.setAttributes(dattributes)
out.addFeature(feature)
featurecount += 1
Expand Down Expand Up @@ -1056,12 +1056,12 @@ def processAlgorithm(self, progress):
totalcount = layer.featureCount()
for feature in layer.getFeatures():
if (comparison == 'begins with') or (comparison == 'contains') or \
(feature.attributes()[selectindex].type() == QVariant.String) or \
isinstance(feature.attributes()[selectindex], basestring) or \
isinstance(comparisonvalue, basestring):
x = unicode(feature.attributes()[selectindex].toString())
x = unicode(feature.attributes()[selectindex])
y = unicode(comparisonvalue)
else:
x = float(feature.attributes()[selectindex].toString())
x = float(feature.attributes()[selectindex])
y = float(comparisonvalue)

match = False
Expand Down Expand Up @@ -1128,14 +1128,14 @@ def processAlgorithm(self, progress):
progress.setPercentage(float(i) / featurecount * 100)
attributes = feature.attributes()
try:
v = unicode(attributes[idx].toString())
v = unicode(attributes[idx])
if '%' in v:
v = v.replace('%', "")
attributes[idx] = float(attributes[idx]) / float(100)
else:
attributes[idx] = float(attributes[idx])
except:
attributes[idx] = QVariant()
attributes[idx] = None

feature.setAttributes(attributes)
out.addFeature(feature)
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/core/LayerExporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def exportVectorLayer(layer):
will get exported.
It also export to a new file if the original one contains non-ascii characters'''
settings = QSettings()
systemEncoding = settings.value( "/UI/encoding", "System" ).toString()
systemEncoding = settings.value( "/UI/encoding", "System" )

filename = os.path.basename(unicode(layer.source()))
idx = filename.rfind(".")
Expand Down Expand Up @@ -110,7 +110,7 @@ def exportTable( table):
Currently, the output is restricted to dbf.
It also export to a new file if the original one contains non-ascii characters'''
settings = QSettings()
systemEncoding = settings.value( "/UI/encoding", "System" ).toString()
systemEncoding = settings.value( "/UI/encoding", "System" )
output = SextanteUtils.getTempFilename("dbf")
provider = table.dataProvider()
isASCII=True
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/sextante/core/QGisLayers.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def load(fileName, name = None, crs = None, style = None):
settings = QSettings()
if crs != None:
prjSetting = settings.value("/Projections/defaultBehaviour")
settings.setValue("/Projections/defaultBehaviour", QVariant(""))
settings.setValue("/Projections/defaultBehaviour", "")
if name == None:
name = path.split(fileName)[1]
qgslayer = QgsVectorLayer(fileName, name , 'ogr')
Expand Down Expand Up @@ -184,7 +184,7 @@ def getObjectFromUri(uri, forceLoad = True):
if forceLoad:
settings = QSettings()
prjSetting = settings.value("/Projections/defaultBehaviour")
settings.setValue("/Projections/defaultBehaviour", QVariant(""))
settings.setValue("/Projections/defaultBehaviour", "")
#if is not opened, we open it
layer = QgsVectorLayer(uri, uri , 'ogr')
if layer.isValid():
Expand All @@ -197,7 +197,7 @@ def getObjectFromUri(uri, forceLoad = True):
settings.setValue("/Projections/defaultBehaviour", prjSetting)
return layer
if prjSetting:
settings.setValue("/Projections/defaultBehaviour", prjSetting)
settings.setValue("/Projections/defaultBehaviour", prjSetting)
else:
return None

Expand Down
8 changes: 2 additions & 6 deletions python/plugins/sextante/core/SextanteTableWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, fileName, encoding, fields):

if encoding is None:
settings = QSettings()
encoding = settings.value("/SextanteQGIS/encoding", "System").toString()
encoding = settings.value("/SextanteQGIS/encoding", "System")

if not fileName.endswith("csv"):
fileName += ".csv"
Expand All @@ -44,11 +44,7 @@ def __init__(self, fileName, encoding, fields):
file.write("\n")
file.close()

def addRecord(self, values):
for i in range(len(values)):
if isinstance(values[i], QVariant):
values[i] = values[i].toString()

def addRecord(self, values):
file = open(self.fileName, "a")
file.write(";".join([unicode(value) for value in values]))
file.write("\n")
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/core/SextanteVectorWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, fileName, encoding, fields, geometryType, crs, options=None):

if encoding is None:
settings = QSettings()
encoding = settings.value("/SextanteQGIS/encoding", "System").toString()
encoding = settings.value("/SextanteQGIS/encoding", "System")

if self.fileName.startswith(self.MEMORY_LAYER_PREFIX):
self.isMemory = True
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/sextante/gdal/GdalUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ class GdalUtils:
@staticmethod
def runGdal(commands, progress):
settings = QSettings()
path = str(settings.value( "/GdalTools/gdalPath", QVariant( "" ) ).toString())
envval = str(os.getenv("PATH"))
path = unicode(settings.value( "/GdalTools/gdalPath", ""))
envval = unicode(os.getenv("PATH"))
if not path.lower() in envval.lower().split(os.pathsep):
envval += "%s%s" % (os.pathsep, str(path))
envval += "%s%s" % (os.pathsep, path)
os.putenv( "PATH", envval )
loglines = []
loglines.append("GDAL execution console output")
Expand Down
3 changes: 1 addition & 2 deletions python/plugins/sextante/gui/AlgorithmExecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
from sextante.core.SextanteUtils import SextanteUtils
from sextante.tools.vector import getfeatures
from sextante.gui.SextantePostprocessing import SextantePostprocessing
import sextante
import sys

class AlgorithmExecutor(QThread):
Expand Down Expand Up @@ -73,7 +72,7 @@ def setConsoleInfo(self, info):

#generate all single-feature layers
settings = QSettings()
systemEncoding = settings.value( "/UI/encoding", "System" ).toString()
systemEncoding = settings.value( "/UI/encoding", "System" )
layerfile = alg.getParameterValue(self.parameterToIterate)
layer = QGisLayers.getObjectFromUri(layerfile, False)
provider = layer.dataProvider()
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/gui/BatchInputSelectionPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ def __init__(self, param, row, col, batchDialog, parent = None):

def showSelectionDialog(self):
settings = QtCore.QSettings()
text = str(self.text.text())
text = unicode(self.text.text())
if os.path.isdir(text):
path = text
elif os.path.isdir(os.path.dirname(text)):
path = os.path.dirname(text)
elif settings.contains("/SextanteQGIS/LastInputPath"):
path = str(settings.value( "/SextanteQGIS/LastInputPath",QtCore.QVariant("")).toString())
path = settings.value( "/SextanteQGIS/LastInputPath")
else:
path = ""

Expand Down
8 changes: 4 additions & 4 deletions python/plugins/sextante/gui/BatchOutputSelectionPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ def showSelectionDialog(self):
elif isinstance(param, ParameterBoolean):
s = str(widget.currentIndex() == 0)
elif isinstance(param, ParameterSelection):
s = str(widget.currentText())
s = unicode(widget.currentText())
elif isinstance(param, ParameterFixedTable):
s = str(widget.table)
s = unicode(widget.table)
else:
s = str(widget.text())
s = unicode(widget.text())
name = filename[:filename.rfind(".")] + s + filename[filename.rfind("."):]
self.table.cellWidget(i + self.row, self.col).setValue(name)
except:
Expand All @@ -100,5 +100,5 @@ def setValue(self, text):
return self.text.setText(text)

def getValue(self):
return str(self.text.text())
return unicode(self.text.text())

2 changes: 1 addition & 1 deletion python/plugins/sextante/gui/ConfigDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def edit(self, item, column):
def fillTree(self):
self.items = {}
self.tree.clear()
text = str(self.searchBox.text())
text = unicode(self.searchBox.text())
settings = SextanteConfig.getSettings()
priorityKeys = ['General', "Models", "Scripts"]
for group in priorityKeys:
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/gui/CouldNotLoadResultsDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def setupUi(self):
QtCore.QMetaObject.connectSlotsByName(self)

def linkClicked(self, url):
webbrowser.open(str(url.toString()))
webbrowser.open(str(url))

def closeButtonPressed(self):
self.close()
10 changes: 5 additions & 5 deletions python/plugins/sextante/gui/FileSelectionPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,29 @@ def __init__(self, isFolder):
def showSelectionDialog(self):
# find the file dialog's working directory
settings = QtCore.QSettings()
text = str(self.text.text())
text = unicode(self.text.text())
if os.path.isdir(text):
path = text
elif os.path.isdir( os.path.dirname(text) ):
path = os.path.dirname(text)
elif settings.contains("/SextanteQGIS/LastInputPath"):
path = str(settings.value( "/SextanteQGIS/LastInputPath",QtCore.QVariant( "" ) ).toString())
path = settings.value( "/SextanteQGIS/LastInputPath")
else:
path = ""

if self.isFolder:
folder = QtGui.QFileDialog.getExistingDirectory (self, "Select folder", path)
if folder:
self.text.setText(str(folder))
settings.setValue("/SextanteQGIS/LastInputPath", os.path.dirname(str(folder)))
settings.setValue("/SextanteQGIS/LastInputPath", os.path.dirname(unicode(folder)))
else:
filenames = QtGui.QFileDialog.getOpenFileNames(self, "Open file", path, "*.*")
if filenames:
self.text.setText(str(filenames.join(";")))
settings.setValue("/SextanteQGIS/LastInputPath", os.path.dirname(str(filenames[0])))
settings.setValue("/SextanteQGIS/LastInputPath", os.path.dirname(unicode(filenames[0])))

def getValue(self):
s = str(self.text.text())
s = unicode(self.text.text())
if SextanteUtils.isWindows():
s = s.replace("\\", "/")
return s
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/gui/FixedTableDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def okPressed(self):
for i in range(self.table.rowCount()):
self.rettable.append(list())
for j in range(self.table.columnCount()):
self.rettable[i].append(str(self.table.item(i,j).text()))
self.rettable[i].append(unicode(self.table.item(i,j).text()))
self.close()

def cancelPressed(self):
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/gui/InputLayerSelectorPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ def __init__(self, options):
def showSelectionDialog(self):
# find the file dialog's working directory
settings = QtCore.QSettings()
text = str(self.text.currentText())
text = unicode(self.text.currentText())
if os.path.isdir(text):
path = text
elif os.path.isdir( os.path.dirname(text) ):
path = os.path.dirname(text)
elif settings.contains("/SextanteQGIS/LastInputPath"):
path = str(settings.value( "/SextanteQGIS/LastInputPath",QtCore.QVariant( "" ) ).toString())
path = settings.value( "/SextanteQGIS/LastInputPath")
else:
path = ""

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/gui/MissingDependencyDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def setupUi(self):
QtCore.QMetaObject.connectSlotsByName(self)

def linkClicked(self, url):
webbrowser.open(str(url.toString()))
webbrowser.open(str(url))

def closeButtonPressed(self):
self.close()
8 changes: 4 additions & 4 deletions python/plugins/sextante/gui/OutputSelectionPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ def saveToFile(self):
filefilter = self.output.getFileFilter(self.alg)
settings = QSettings()
if settings.contains("/SextanteQGIS/LastOutputPath"):
path = str(settings.value( "/SextanteQGIS/LastOutputPath", QVariant( "" ) ).toString())
path = settings.value( "/SextanteQGIS/LastOutputPath")
else:
path = SextanteConfig.getSetting(SextanteConfig.OUTPUT_FOLDER)
lastEncoding = settings.value("/SextanteQGIS/encoding", "System").toString()
lastEncoding = settings.value("/SextanteQGIS/encoding", "System")
fileDialog = QgsEncodingFileDialog(self, "Save file", QString(path), filefilter, lastEncoding)
fileDialog.setFileMode(QFileDialog.AnyFile)
fileDialog.setAcceptMode(QFileDialog.AcceptSave)
Expand All @@ -91,11 +91,11 @@ def saveToFile(self):
self.output.encoding = encoding
filename= unicode(files.first())
self.text.setText(filename)
settings.setValue("/SextanteQGIS/LastOutputPath", os.path.dirname(str(filename)))
settings.setValue("/SextanteQGIS/LastOutputPath", os.path.dirname(filename))
settings.setValue("/SextanteQGIS/encoding", encoding)

def getValue(self):
filename = str(self.text.text())
filename = unicode(self.text.text())
if filename.strip() == "" or filename == OutputSelectionPanel.SAVE_TO_TEMP_FILE:
return None
if filename.startswith("memory:"):
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/sextante/gui/RenderingStyleFilePanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ def __init__(self):
def showSelectionDialog(self):
filename = QtGui.QFileDialog.getOpenFileName(self, "Select style file", "", "*.qml")
if filename:
self.text.setText(str(filename))
self.text.setText(unicode(filename))

def setText(self, text):
self.text.setText(str(text))
self.text.setText(unicode(text))

def getValue(self):
filename = str(self.text.text())
filename = unicode(self.text.text())
return filename
7 changes: 3 additions & 4 deletions python/plugins/sextante/gui/SextanteToolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(self, iface):
settings = QSettings()
if not settings.contains(self.USE_CATEGORIES):
settings.setValue(self.USE_CATEGORIES, True)
useCategories = settings.value(self.USE_CATEGORIES).toBool()
useCategories = settings.value(self.USE_CATEGORIES, type = bool)
if useCategories:
self.modeComboBox.setCurrentIndex(0)
else:
Expand Down Expand Up @@ -174,7 +174,7 @@ def executeAlgorithm(self):

def fillTree(self):
settings = QSettings()
useCategories = settings.value(self.USE_CATEGORIES).toBool()
useCategories = settings.value(self.USE_CATEGORIES, type = bool)
if useCategories:
self.fillTreeUsingCategories()
else:
Expand All @@ -192,7 +192,6 @@ def addRecentAlgorithms(self, updating):
recentItem = self.algorithmTree.topLevelItem(0)
treeWidget = recentItem.treeWidget()
treeWidget.takeTopLevelItem(treeWidget.indexOfTopLevelItem(recentItem))
#self.algorithmTree.removeItemWidget(first, 0)

recentItem = QTreeWidgetItem()
recentItem.setText(0, self.tr("Recently used algorithms"))
Expand Down Expand Up @@ -362,7 +361,7 @@ class TreeAlgorithmItem(QTreeWidgetItem):

def __init__(self, alg):
settings = QSettings()
useCategories = settings.value(SextanteToolbox.USE_CATEGORIES)
useCategories = settings.value(SextanteToolbox.USE_CATEGORIES, type = bool)
QTreeWidgetItem.__init__(self)
self.alg = alg
icon = alg.getIcon()
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/gui/TestTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ def createTest(text):
attrs = feature.attributes()
s+="\tfeature=features.next()\n"
s+="\tattrs=feature.attributes()\n"
s+="\texpectedvalues=[" + ",".join(['"' + str(attr.toString()) + '"' for attr in attrs]) + "]\n"
s+="\tvalues=[str(attr.toString()) for attr in attrs]\n"
s+="\texpectedvalues=[" + ",".join(['"' + str(attr) + '"' for attr in attrs]) + "]\n"
s+="\tvalues=[str(attr) for attr in attrs]\n"
s+="\tself.assertEqual(expectedvalues, values)\n"
s+="\twkt='" + str(feature.geometry().exportToWkt()) + "'\n"
s+="\tself.assertEqual(wkt, str(feature.geometry().exportToWkt()))"
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/gui/UnthreadedAlgorithmExecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def runalg(alg, progress):
def runalgIterating(alg,paramToIter,progress):
#generate all single-feature layers
settings = QSettings()
systemEncoding = settings.value( "/UI/encoding", "System" ).toString()
systemEncoding = settings.value( "/UI/encoding", "System" )
layerfile = alg.getParameterValue(paramToIter)
layer = QGisLayers.getObjectFromUri(layerfile, False)
feat = QgsFeature()
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/modeler/ModelerDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def addAlgorithm(self):

def fillAlgorithmTree(self):
settings = QSettings()
useCategories = settings.value(self.USE_CATEGORIES).toBool()
useCategories = settings.value(self.USE_CATEGORIES, type = bool)
if useCategories:
self.fillAlgorithmTreeUsingCategories()
else:
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/modeler/ModelerParametersDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ def setParamValue(self, param, widget):
name = self.getSafeNameForHarcodedParameter(param)
value = AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, name)
self.params[param.name] = value
self.values[name] = str(widget.text())
self.values[name] = unicode(widget.text())
return True

def getSafeNameForHarcodedParameter(self, param):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/outputs/OutputTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ def getTableWriter(self, fields):

if self.encoding is None:
settings = QSettings()
self.encoding = settings.value("/SextanteQGIS/encoding", "System").toString()
self.encoding = settings.value("/SextanteQGIS/encoding", "System")

return SextanteTableWriter(self.value, self.encoding, fields)
2 changes: 1 addition & 1 deletion python/plugins/sextante/outputs/OutputVector.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def getVectorWriter(self, fields, geomType, crs, options=None):

if self.encoding is None:
settings = QSettings()
self.encoding = settings.value("/SextanteQGIS/encoding", "System").toString()
self.encoding = settings.value("/SextanteQGIS/encoding", "System")

w = SextanteVectorWriter(self.value, self.encoding, fields, geomType, crs, options)
self.memoryLayer = w.memLayer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
progress.setPercentage(int((100 * nElement)/nFeat))
nElement += 1
attrs = inFeat.attributes()
clazz = attrs[class_field_index].toString()
value = attrs[value_field_index].toString()
clazz = attrs[class_field_index]
value = attrs[value_field_index]
if clazz not in classes:
classes[clazz] = []
if value not in classes[clazz]:
Expand All @@ -54,8 +54,8 @@
inGeom = inFeat.geometry()
outFeat.setGeometry(inGeom)
attrs = inFeat.attributes()
clazz = attrs[class_field_index].toString()
attrs.append(QVariant(len(classes[clazz])))
clazz = attrs[class_field_index]
attrs.append(len(classes[clazz]))
outFeat.setAttributes(attrs)
writer.addFeature(outFeat)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
progress.setPercentage(int((100 * nElement)/nFeat))
nElement += 1
atMap = inFeat.attributes()
clazz = atMap[class_field_index].toString()
clazz = atMap[class_field_index]
if clazz not in writers:
outputFile = output + "_" + str(len(writers)) + ".shp"
writers[clazz] = SextanteVectorWriter(outputFile, None, fields, provider.geometryType(), layer.crs() )
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/script/scripts/Summarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
attrs = ft.attributes()
for f in range(len(fields)):
try:
mean[f] += float(attrs[f].toDouble()[0])
mean[f] += float(attrs[f])
except:
pass
count += 1
Expand All @@ -33,5 +33,5 @@
outFeat = QgsFeature()
meanPoint = QgsPoint(x, y)
outFeat.setGeometry(QgsGeometry.fromPoint(meanPoint))
outFeat.setAttributes([QVariant(v) for v in mean])
outFeat.setAttributes([v for v in mean])
outputLayer.addFeature(outFeat)
5 changes: 3 additions & 2 deletions python/plugins/sextante/tools/vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,16 @@ def values(layer, *attributes):
'''Returns the values in the attributes table of a vector layer, for the passed fields.
Field can be passed as field names or as zero-based field indices.
Returns a dict of lists, with the passed field identifiers as keys.
It considers the existing selection'''
It considers the existing selection.
It assummes fields are numeric or contain values that can be parsed to a number'''
ret = {}
for attr in attributes:
index = resolveFieldIndex(layer, attr)
values = []
features = QGisLayers.features(layer)
for feature in features:
try:
v = float(feature.attributes()[index].toString())
v = float(feature.attributes()[index])
values.append(v)
except:
values.append(None)
Expand Down