Skip to content

Commit 4386860

Browse files
committed
[gdaltools] More SIP API update
1 parent 1f10010 commit 4386860

14 files changed

+192
-192
lines changed

python/plugins/GdalTools/tools/GdalTools_utils.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def getRasterSRS( parent, fileName ):
293293
if processSRS.waitForFinished():
294294
arr = processSRS.readAllStandardOutput()
295295
processSRS.close()
296-
296+
297297
arr = str(arr)
298298
if arr == '':
299299
return ''
@@ -545,7 +545,7 @@ def getSupportedRasters(self):
545545
# XXX add check for SDTS; in that case we want (*CATD.DDF)
546546

547547
#TODO fix and test
548-
#glob << QString("*." + extensions.replace("/", " *.")).split(" ")
548+
#glob.append( QString("*." + extensions.replace("/", " *.")).split(" "))
549549
glob.append(string.split("*." + string.replace(extensions,"/", " *."), sep=(" ")))
550550

551551
# Add only the first JP2 driver found to the filter list (it's the one GDAL uses)
@@ -837,7 +837,7 @@ def setProcessEnvironment(process):
837837
if env.contains( QRegExp( "^%s=(.*)" % name, Qt.CaseInsensitive ) ):
838838
env.replaceInStrings( QRegExp( "^%s=(.*)" % name, Qt.CaseInsensitive ), "%s=\\1%s%s" % (name, sep, gdalPath) )
839839
else:
840-
env << "%s=%s" % (name, val)
840+
env.append( "%s=%s" % (name, val))
841841
process.setEnvironment( env )
842842

843843

python/plugins/GdalTools/tools/doClipper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def getArgsModeExtent(self):
140140
arguments = []
141141
if self.noDataCheck.isChecked():
142142
arguments.append("-a_nodata")
143-
arguments << str(self.noDataSpin.value())
143+
arguments.append( str(self.noDataSpin.value()))
144144
if self.extentModeRadio.isChecked() and self.extentSelector.isCoordsValid():
145145
rect = self.extentSelector.getExtent()
146146
if rect != None:

python/plugins/GdalTools/tools/doDEM.py

+25-25
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def onLayersChanged(self):
9999
def fillInputFileEdit(self):
100100
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
101101
inputFile = Utils.FileDialog.getOpenFileName(self, self.tr( "Select the file for DEM" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
102-
if inputFile.isEmpty():
102+
if not inputFile:
103103
return
104104
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
105105

@@ -109,7 +109,7 @@ def fillInputFileEdit(self):
109109
def fillOutputFileEdit(self):
110110
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
111111
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter )
112-
if outputFile.isEmpty():
112+
if not outputFile:
113113
return
114114
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
115115

@@ -119,52 +119,52 @@ def fillOutputFileEdit(self):
119119

120120
def fillColorConfigFileEdit(self):
121121
configFile = Utils.FileDialog.getOpenFileName(self, self.tr( "Select the color configuration file" ))
122-
if configFile.isEmpty():
122+
if not configFile:
123123
return
124124
self.configSelector.setFilename(configFile)
125125

126126
def getArguments(self):
127127
mode = self.modes[ self.modeCombo.currentIndex() ]
128-
arguments = QStringList()
129-
arguments << mode
130-
arguments << self.getInputFileName()
128+
arguments = []
129+
arguments.append( mode)
130+
arguments.append( self.getInputFileName())
131131
if mode == "color-relief":
132-
arguments << self.configSelector.filename()
132+
arguments.append( self.configSelector.filename())
133133
outputFn = self.getOutputFileName()
134-
arguments << outputFn
134+
arguments.append( outputFn)
135135
if mode == "hillshade":
136-
arguments << "-z" << str(self.hillshadeZFactorSpin.value())
137-
arguments << "-s" << str(self.hillshadeScaleSpin.value())
138-
arguments << "-az" << str(self.hillshadeAzimuthSpin.value())
139-
arguments << "-alt" << str(self.hillshadeAltitudeSpin.value())
136+
arguments.extend( "-z", self.hillshadeZFactorSpin.value())
137+
arguments.extend( "-s" , self.hillshadeScaleSpin.value())
138+
arguments.extend( "-az" , self.hillshadeAzimuthSpin.value())
139+
arguments.extend( "-alt" , self.hillshadeAltitudeSpin.value())
140140
elif mode == "slope":
141141
if self.slopePercentCheck.isChecked():
142-
arguments << "-p"
143-
arguments << "-s" << str(self.slopeScaleSpin.value())
142+
arguments.append( "-p")
143+
arguments.extend( "-s" , self.slopeScaleSpin.value())
144144
elif mode == "aspect":
145145
if self.aspectTrigonometricCheck.isChecked():
146-
arguments << "-trigonometric"
146+
arguments.append( "-trigonometric")
147147
if self.aspectZeroForFlatCheck.isChecked():
148-
arguments << "-zero_for_flat"
148+
arguments.append( "-zero_for_flat")
149149
elif mode == "color-relief":
150150
if self.colorAlphaCheck.isChecked():
151-
arguments << "-alpha"
151+
arguments.append( "-alpha")
152152
if self.colorMatchGroupBox.isChecked():
153153
if self.colorExactRadio.isChecked():
154-
arguments << "-exact_color_entry"
154+
arguments.append( "-exact_color_entry")
155155
elif self.colorNearestRadio.isChecked():
156-
arguments << "-nearest_color_entry"
156+
arguments.append( "-nearest_color_entry")
157157
if self.algorithmCheck.isChecked():
158-
arguments << "-alg" << "ZevenbergenThorne"
158+
arguments.extend( "-alg", "ZevenbergenThorne")
159159
if self.computeEdgesCheck.isChecked():
160-
arguments << "-compute_edges"
160+
arguments.append( "-compute_edges")
161161
if self.bandCheck.isChecked():
162-
arguments << "-b" << str(self.bandSpin.value())
163-
if not outputFn.isEmpty():
164-
arguments << "-of" << self.outputFormat
162+
arguments.extend( "-b" , self.bandSpin.value())
163+
if outputFn:
164+
arguments.extend( "-of", self.outputFormat)
165165
if self.creationOptionsGroupBox.isChecked():
166166
for opt in self.creationOptionsWidget.options():
167-
arguments << "-co" << opt
167+
arguments.extend( "-co", opt)
168168
# set creation options filename/layer for validation
169169
if self.inSelector.layer():
170170
self.creationOptionsWidget.setRasterLayer(self.inSelector.layer())

python/plugins/GdalTools/tools/doFillNodata.py

+25-25
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,15 @@ def fillInputFile( self ):
111111
self.tr( "Select the files to analyse" ),
112112
Utils.FileFilter.allRastersFilter(),
113113
lastUsedFilter )
114-
if inputFile.isEmpty():
114+
if not inputFile:
115115
return
116116
Utils.FileFilter.setLastUsedRasterFilter( lastUsedFilter )
117117
self.inSelector.setFilename( inputFile )
118118

119119
def fillOutputFile( self ):
120120
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
121121
outputFile = Utils.FileDialog.getSaveFileName( self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter )
122-
if outputFile.isEmpty():
122+
if not outputFile:
123123
return
124124
Utils.FileFilter.setLastUsedRasterFilter( lastUsedFilter )
125125

@@ -132,52 +132,52 @@ def fillMaskFile( self ):
132132
self.tr( "Select the files to analyse" ),
133133
Utils.FileFilter.allRastersFilter(),
134134
lastUsedFilter )
135-
if inputFile.isEmpty():
135+
if not inputFile:
136136
return
137137
Utils.FileFilter.setLastUsedRasterFilter( lastUsedFilter )
138138
self.maskSelector.setFilename( inputFile )
139139

140140
def fillInputDir( self ):
141141
inputDir = Utils.FileDialog.getExistingDirectory( self, self.tr( "Select the input directory with files" ))
142-
if inputDir.isEmpty():
142+
if not inputDir:
143143
return
144144
self.inSelector.setFilename( inputDir )
145145

146146
def fillOutputDir( self ):
147147
outputDir = Utils.FileDialog.getExistingDirectory( self, self.tr( "Select the output directory to save the results to" ) )
148-
if outputDir.isEmpty():
148+
if not outputDir:
149149
return
150150
self.outSelector.setFilename( outputDir )
151151

152152
def getArguments(self):
153-
arguments = QStringList()
153+
arguments = []
154154
maskFile = self.maskSelector.filename()
155155
if self.distanceCheck.isChecked() and self.distanceSpin.value() != 0:
156-
arguments << "-md"
157-
arguments << self.distanceSpin.text()
156+
arguments.append( "-md")
157+
arguments.append( self.distanceSpin.text())
158158
if self.smoothCheck.isChecked() and self.smoothSpin.value() != 0:
159-
arguments << "-si"
160-
arguments << str( self.smoothSpin.value() )
159+
arguments.append( "-si")
160+
arguments.append( str( self.smoothSpin.value() ))
161161
if self.bandCheck.isChecked() and self.bandSpin.value() != 0:
162-
arguments << "-b"
163-
arguments << str( self.bandSpin.value() )
164-
if self.maskCheck.isChecked() and not maskFile.isEmpty():
165-
arguments << "-mask"
166-
arguments << maskFile
162+
arguments.append( "-b")
163+
arguments.append( str( self.bandSpin.value() ))
164+
if self.maskCheck.isChecked() and maskFile:
165+
arguments.append( "-mask")
166+
arguments.append( maskFile)
167167
if self.nomaskCheck.isChecked():
168-
arguments << "-nomask"
168+
arguments.append( "-nomask")
169169
if self.isBatchEnabled():
170170
if self.formatCombo.currentIndex() != 0:
171-
arguments << "-of"
172-
arguments << Utils.fillRasterOutputFormat( self.formatCombo.currentText() )
171+
arguments.append( "-of")
172+
arguments.append( Utils.fillRasterOutputFormat( self.formatCombo.currentText() ))
173173
return arguments
174174
else:
175175
outputFn = self.getOutputFileName()
176-
if not outputFn.isEmpty():
177-
arguments << "-of"
178-
arguments << self.outputFormat
179-
arguments << self.getInputFileName()
180-
arguments << outputFn
176+
if outputFn:
177+
arguments.append( "-of")
178+
arguments.append( self.outputFormat)
179+
arguments.append( self.getInputFileName())
180+
arguments.append( outputFn)
181181
return arguments
182182

183183
def onLayersChanged( self ):
@@ -206,7 +206,7 @@ def updateProgress(self, index, total):
206206

207207
def batchRun(self):
208208
exts = self.formatCombo.currentText().remove( QRegExp('^.*\(') ).remove( QRegExp('\).*$') ).split( " " )
209-
if not exts.isEmpty() and exts != "*" and exts != "*.*":
209+
if exts and exts != "*" and exts != "*.*":
210210
outExt = exts[ 0 ].remove( "*" )
211211
else:
212212
outExt = ".tif"
@@ -232,7 +232,7 @@ def batchRun(self):
232232
outFile = re.sub( f, "\.[a-zA-Z0-9]{2,4}", outExt )
233233
self.outFiles.append( outDir + "/" + outFile )
234234

235-
self.errors = QStringList()
235+
self.errors = []
236236
self.batchIndex = 0
237237
self.batchTotal = len( self.inFiles )
238238
self.setProgressRange( self.batchTotal )

python/plugins/GdalTools/tools/doGrid.py

+26-26
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def fillFieldsCombo(self):
102102
def fillInputFileEdit(self):
103103
lastUsedFilter = Utils.FileFilter.lastUsedVectorFilter()
104104
inputFile, encoding = Utils.FileDialog.getOpenFileName(self, self.tr( "Select the input file for Grid" ), Utils.FileFilter.allVectorsFilter(), lastUsedFilter, True)
105-
if inputFile.isEmpty():
105+
if not inputFile:
106106
return
107107
Utils.FileFilter.setLastUsedVectorFilter(lastUsedFilter)
108108

@@ -114,44 +114,44 @@ def fillInputFileEdit(self):
114114
def fillOutputFileEdit(self):
115115
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
116116
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter )
117-
if outputFile.isEmpty():
117+
if not outputFile:
118118
return
119119
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
120120

121121
self.outputFormat = Utils.fillRasterOutputFormat( lastUsedFilter, outputFile )
122122
self.outSelector.setFilename(outputFile)
123123

124124
def getArguments(self):
125-
arguments = QStringList()
125+
arguments = []
126126
if self.zfieldCheck.isChecked() and self.zfieldCombo.currentIndex() >= 0:
127-
arguments << "-zfield"
128-
arguments << self.zfieldCombo.currentText()
127+
arguments.append( "-zfield")
128+
arguments.append( self.zfieldCombo.currentText())
129129
inputFn = self.getInputFileName()
130-
if not inputFn.isEmpty():
131-
arguments << "-l"
132-
arguments << QFileInfo( inputFn ).baseName()
130+
if inputFn:
131+
arguments.append( "-l")
132+
arguments.append( QFileInfo( inputFn ).baseName())
133133
if self.extentGroup.isChecked():
134134
rect = self.extentSelector.getExtent()
135135
if rect != None:
136-
arguments << "-txe"
137-
arguments << str(rect.xMinimum())
138-
arguments << str(rect.xMaximum())
139-
arguments << "-tye"
140-
arguments << str(rect.yMaximum())
141-
arguments << str(rect.yMinimum())
136+
arguments.append( "-txe")
137+
arguments.append( str(rect.xMinimum()))
138+
arguments.append( str(rect.xMaximum()))
139+
arguments.append( "-tye")
140+
arguments.append( str(rect.yMaximum()))
141+
arguments.append( str(rect.yMinimum()))
142142
if self.algorithmCheck.isChecked() and self.algorithmCombo.currentIndex() >= 0:
143-
arguments << "-a"
144-
arguments << self.algorithmArguments(self.algorithmCombo.currentIndex())
143+
arguments.append( "-a")
144+
arguments.append( self.algorithmArguments(self.algorithmCombo.currentIndex()))
145145
if self.resizeGroupBox.isChecked():
146-
arguments << "-outsize"
147-
arguments << str( self.widthSpin.value() )
148-
arguments << str( self.heightSpin.value() )
146+
arguments.append( "-outsize")
147+
arguments.append( str( self.widthSpin.value() ))
148+
arguments.append( str( self.heightSpin.value() ))
149149
outputFn = self.getOutputFileName()
150-
if not outputFn.isEmpty():
151-
arguments << "-of"
152-
arguments << self.outputFormat
153-
arguments << inputFn
154-
arguments << outputFn
150+
if outputFn:
151+
arguments.append( "-of")
152+
arguments.append( self.outputFormat)
153+
arguments.append( inputFn)
154+
arguments.append( outputFn)
155155
return arguments
156156

157157
def getInputFileName(self):
@@ -165,7 +165,7 @@ def addLayerIntoCanvas(self, fileInfo):
165165

166166
def algorithmArguments(self, index):
167167
algorithm = self.algorithm[index]
168-
arguments = QStringList()
168+
arguments = []
169169
if algorithm == "invdist":
170170
arguments.append(algorithm)
171171
arguments.append("power=" + str(self.invdistPowerSpin.value()))
@@ -201,7 +201,7 @@ def algorithmArguments(self, index):
201201
def loadFields(self, vectorFile = ''):
202202
self.zfieldCombo.clear()
203203

204-
if vectorFile.isEmpty():
204+
if not vectorFile:
205205
return
206206

207207
try:

python/plugins/GdalTools/tools/doNearBlack.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def onLayersChanged(self):
6565
def fillInputFileEdit(self):
6666
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
6767
inputFile = Utils.FileDialog.getOpenFileName(self, self.tr( "Select the input file for Near Black" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter )
68-
if inputFile.isEmpty():
68+
if not inputFile:
6969
return
7070
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
7171

@@ -74,22 +74,22 @@ def fillInputFileEdit(self):
7474
def fillOutputFileEdit(self):
7575
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
7676
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
77-
if outputFile.isEmpty():
77+
if not outputFile:
7878
return
7979
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
8080

8181
self.outSelector.setFilename(outputFile)
8282

8383
def getArguments(self):
84-
arguments = QStringList()
84+
arguments = []
8585
if self.whiteCheckBox.isChecked():
86-
arguments << "-white"
86+
arguments.append( "-white")
8787
if self.nearCheck.isChecked():
88-
arguments << "-near"
89-
arguments << str(self.nearSpin.value())
90-
arguments << "-o"
91-
arguments << self.getOutputFileName()
92-
arguments << self.getInputFileName()
88+
arguments.append( "-near")
89+
arguments.append( str(self.nearSpin.value()))
90+
arguments.append( "-o")
91+
arguments.append( self.getOutputFileName())
92+
arguments.append( self.getInputFileName())
9393
return arguments
9494

9595
def getOutputFileName(self):

0 commit comments

Comments
 (0)