@@ -116,7 +116,7 @@ def onLayersChanged(self):
116
116
def fillInputFile (self ):
117
117
lastUsedFilter = Utils .FileFilter .lastUsedRasterFilter ()
118
118
inputFile = Utils .FileDialog .getOpenFileName (self , self .tr ( "Select the input file for Warp" ), Utils .FileFilter .allRastersFilter (), lastUsedFilter )
119
- if inputFile . isEmpty () :
119
+ if not inputFile :
120
120
return
121
121
Utils .FileFilter .setLastUsedRasterFilter (lastUsedFilter )
122
122
self .inSelector .setFilename (inputFile )
@@ -127,7 +127,7 @@ def fillInputFile(self):
127
127
def fillOutputFileEdit (self ):
128
128
lastUsedFilter = Utils .FileFilter .lastUsedRasterFilter ()
129
129
outputFile = Utils .FileDialog .getSaveFileName (self , self .tr ( "Select the raster file to save the results to" ), Utils .FileFilter .allRastersFilter (), lastUsedFilter )
130
- if outputFile . isEmpty () :
130
+ if not outputFile :
131
131
return
132
132
Utils .FileFilter .setLastUsedRasterFilter (lastUsedFilter )
133
133
@@ -137,15 +137,15 @@ def fillOutputFileEdit(self):
137
137
def fillMaskFile (self ):
138
138
lastUsedFilter = Utils .FileFilter .lastUsedVectorFilter ()
139
139
maskFile = Utils .FileDialog .getOpenFileName (self , self .tr ( "Select the mask file" ), Utils .FileFilter .allVectorsFilter (), lastUsedFilter )
140
- if maskFile . isEmpty () :
140
+ if not maskFile :
141
141
return
142
142
Utils .FileFilter .setLastUsedVectorFilter (lastUsedFilter )
143
143
self .maskSelector .setFilename (maskFile )
144
144
145
145
146
146
def fillInputDir ( self ):
147
147
inputDir = Utils .FileDialog .getExistingDirectory ( self , self .tr ( "Select the input directory with files to Warp" ))
148
- if inputDir . isEmpty () :
148
+ if not inputDir :
149
149
return
150
150
151
151
self .inSelector .setFilename ( inputDir )
@@ -154,13 +154,13 @@ def fillInputDir( self ):
154
154
workDir = QDir ( inputDir )
155
155
workDir .setFilter ( QDir .Files | QDir .NoSymLinks | QDir .NoDotAndDotDot )
156
156
workDir .setNameFilters ( filter )
157
- if workDir .entryList (). count ( ) > 0 :
157
+ if len ( workDir .entryList ()) > 0 :
158
158
fl = inputDir + "/" + workDir .entryList ()[ 0 ]
159
159
self .sourceSRSEdit .setText ( Utils .getRasterSRS ( self , fl ) )
160
160
161
161
def fillOutputDir ( self ):
162
162
outputDir = Utils .FileDialog .getExistingDirectory ( self , self .tr ( "Select the output directory to save the results to" ))
163
- if outputDir . isEmpty () :
163
+ if not outputDir :
164
164
return
165
165
self .outSelector .setFilename ( outputDir )
166
166
@@ -177,54 +177,54 @@ def fillSourceSRSEditDefault(self):
177
177
def refreshSourceSRS (self ):
178
178
crs = Utils .getRasterSRS ( self , self .getInputFileName () )
179
179
self .sourceSRSEdit .setText ( crs )
180
- self .sourceSRSCheck .setChecked ( not crs . isEmpty () )
180
+ self .sourceSRSCheck .setChecked ( crs != '' )
181
181
182
182
def fillTargetSRSEdit (self ):
183
183
dialog = SRSDialog ( "Select the target SRS" , self )
184
184
if dialog .exec_ ():
185
185
self .targetSRSEdit .setText (dialog .getProjection ())
186
186
187
187
def getArguments (self ):
188
- arguments = QStringList ()
189
- if self .sourceSRSCheck .isChecked () and not self .sourceSRSEdit .text (). isEmpty ():
190
- arguments << "-s_srs"
191
- arguments << self .sourceSRSEdit .text ()
192
- if self .targetSRSCheck .isChecked () and not self .targetSRSEdit .text (). isEmpty ():
193
- arguments << "-t_srs"
194
- arguments << self .targetSRSEdit .text ()
188
+ arguments = []
189
+ if self .sourceSRSCheck .isChecked () and self .sourceSRSEdit .text ():
190
+ arguments . append ( "-s_srs" )
191
+ arguments . append ( self .sourceSRSEdit .text () )
192
+ if self .targetSRSCheck .isChecked () and self .targetSRSEdit .text ():
193
+ arguments . append ( "-t_srs" )
194
+ arguments . append ( self .targetSRSEdit .text () )
195
195
if self .resamplingCheck .isChecked () and self .resamplingCombo .currentIndex () >= 0 :
196
- arguments << "-r"
197
- arguments << self .resampling_method [self .resamplingCombo .currentIndex ()]
196
+ arguments . append ( "-r" )
197
+ arguments . append ( self .resampling_method [self .resamplingCombo .currentIndex ()])
198
198
if self .cacheCheck .isChecked ():
199
- arguments << "-wm"
200
- arguments << str (self .cacheSpin .value ())
199
+ arguments . append ( "-wm" )
200
+ arguments . append ( str (self .cacheSpin .value () ))
201
201
if self .resizeGroupBox .isChecked ():
202
- arguments << "-ts"
203
- arguments << str ( self .widthSpin .value () )
204
- arguments << str ( self .heightSpin .value () )
202
+ arguments . append ( "-ts" )
203
+ arguments . append ( str ( self .widthSpin .value () ) )
204
+ arguments . append ( str ( self .heightSpin .value () ) )
205
205
if self .multithreadCheck .isChecked ():
206
- arguments << "-multi"
206
+ arguments . append ( "-multi" )
207
207
if self .noDataCheck .isChecked ():
208
- nodata = self .noDataEdit .text ().trimmed ()
209
- if not nodata . isEmpty () :
210
- arguments << "-dstnodata"
211
- arguments << nodata
208
+ nodata = self .noDataEdit .text ().strip ()
209
+ if nodata :
210
+ arguments . append ( "-dstnodata" )
211
+ arguments . append ( nodata )
212
212
if self .maskCheck .isChecked ():
213
213
mask = self .getMaskFileName ()
214
- if not mask . isEmpty () :
215
- arguments << "-q"
216
- arguments << "-cutline"
217
- arguments << mask
218
- arguments << "-dstalpha"
214
+ if mask :
215
+ arguments . append ( "-q" )
216
+ arguments . append ( "-cutline" )
217
+ arguments . append ( mask )
218
+ arguments . append ( "-dstalpha" )
219
219
if self .isBatchEnabled ():
220
220
return arguments
221
221
222
222
outputFn = self .getOutputFileName ()
223
- if not outputFn . isEmpty () :
224
- arguments << "-of"
225
- arguments << self .outputFormat
226
- arguments << self .getInputFileName ()
227
- arguments << outputFn
223
+ if outputFn :
224
+ arguments . append ( "-of" )
225
+ arguments . append ( self .outputFormat )
226
+ arguments . append ( self .getInputFileName () )
227
+ arguments . append ( outputFn )
228
228
return arguments
229
229
230
230
def getInputFileName (self ):
0 commit comments