Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
indentation update
  • Loading branch information
jef-n committed Apr 15, 2013
1 parent cfe43dc commit a51fd5f
Show file tree
Hide file tree
Showing 54 changed files with 622 additions and 622 deletions.
2 changes: 1 addition & 1 deletion python/plugins/sextante/algs/ftools/ConvexHull.py
Expand Up @@ -71,7 +71,7 @@ def processAlgorithm(self, progress):
GEOS_EXCEPT = True
FEATURE_EXCEPT = True


f = QgsField("value")
f.setType(QVariant.String)
f.setLength(255)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/algs/ftools/ReprojectLayer.py
Expand Up @@ -79,5 +79,5 @@ def processAlgorithm(self, progress):
progress.setPercentage(int(current * total))

del writer

self.crs = targetCrs
2 changes: 1 addition & 1 deletion python/plugins/sextante/gdal/OgrAlgorithm.py
Expand Up @@ -47,7 +47,7 @@ def ogrConnectionString(self, uri):
layer = QGisLayers.getObjectFromUri(uri, False)
if layer == None:
return uri;
provider = layer.dataProvider().name()
provider = layer.dataProvider().name()
if provider == 'spatialite':
#dbname='/geodata/osm_ch.sqlite' table="places" (Geometry) sql=
regex = re.compile("dbname='(.+)'")
Expand Down
34 changes: 17 additions & 17 deletions python/plugins/sextante/gdal/ogr2ogr.py
Expand Up @@ -62,47 +62,47 @@ def defineCharacteristics(self):

#we add the input vector layer. It can have any kind of geometry
#It is a mandatory (not optional) one, hence the False argument
self.addParameter(ParameterVector(self.INPUT_LAYER, "Input layer", ParameterVector.VECTOR_TYPE_ANY, False))
self.addParameter(ParameterSelection(self.DEST_FORMAT, "Destination Format", FORMATS))
self.addParameter(ParameterString(self.DEST_DSCO, "Creation Options", ""))
self.addParameter(ParameterVector(self.INPUT_LAYER, "Input layer", ParameterVector.VECTOR_TYPE_ANY, False))
self.addParameter(ParameterSelection(self.DEST_FORMAT, "Destination Format", FORMATS))
self.addParameter(ParameterString(self.DEST_DSCO, "Creation Options", ""))

self.addOutput(OutputVector(self.OUTPUT_LAYER, "Output layer"))

def processAlgorithm(self, progress):
'''Here is where the processing itself takes place'''

if not gdalAvailable:
raise GeoAlgorithmExecutionException("GDAL bindings not installed.")
raise GeoAlgorithmExecutionException("GDAL bindings not installed.")

input = self.getParameterValue(self.INPUT_LAYER)
ogrLayer = self.ogrConnectionString(input)

output = self.getOutputFromName(self.OUTPUT_LAYER)
outfile = output.value

formatIdx = self.getParameterValue(self.DEST_FORMAT)

ext = EXTS[formatIdx]
if not outfile.endswith(ext):
outfile = outfile + ext;
output.value = outfile

dst_ds = self.ogrConnectionString(outfile)
dst_format = FORMATS[formatIdx]
ogr_dsco = [self.getParameterValue(self.DEST_DSCO)]
ogr_dsco = [self.getParameterValue(self.DEST_DSCO)]

poDS = ogr.Open( ogrLayer, False )
if poDS is None:
raise GeoAlgorithmExecutionException(self.failure(ogrLayer))
raise GeoAlgorithmExecutionException(self.failure(ogrLayer))

if dst_format == "SQLite" and os.path.isfile(dst_ds):
os.remove(dst_ds)
os.remove(dst_ds)
driver = ogr.GetDriverByName(str(dst_format))
poDstDS = driver.CreateDataSource(dst_ds, options = ogr_dsco)
if poDstDS is None:
raise GeoAlgorithmExecutionException("Error creating %s" % dst_ds)
return
self.ogrtransform(poDS, poDstDS, bOverwrite = True)
self.ogrtransform(poDS, poDstDS, bOverwrite = True)


def ogrtransform(self,
Expand Down Expand Up @@ -141,7 +141,7 @@ def ogrtransform(self,
poLayer = poSrcDS.GetLayer(iLayer)

if poLayer is None:
raise GeoAlgorithmExecutionException( "FAILURE: Couldn't fetch advertised layer %d!" % iLayer)
raise GeoAlgorithmExecutionException( "FAILURE: Couldn't fetch advertised layer %d!" % iLayer)

papoLayers[iLayer] = poLayer
iLayer = iLayer + 1
Expand All @@ -156,12 +156,12 @@ def ogrtransform(self,
poLayer = poSrcDS.GetLayerByName(layername)

if poLayer is None:
raise GeoAlgorithmExecutionException("FAILURE: Couldn't fetch advertised layer %s!" % layername)
raise GeoAlgorithmExecutionException("FAILURE: Couldn't fetch advertised layer %s!" % layername)

papoLayers[iLayer] = poLayer
iLayer = iLayer + 1

for poSrcLayer in papoLayers:
for poSrcLayer in papoLayers:
ok = TranslateLayer( poSrcDS, poSrcLayer, poDstDS, papszLCO, pszNewLayerName, \
bTransform, poOutputSRS, poSourceSRS, papszSelFields, \
bAppend, eGType, bOverwrite, eGeomOp, dfGeomOpParam, \
Expand Down
16 changes: 8 additions & 8 deletions python/plugins/sextante/grass/GrassAlgorithm.py
Expand Up @@ -78,7 +78,7 @@ def getIcon(self):
return QIcon(os.path.dirname(__file__) + "/../images/grass.png")

def helpFile(self):
return 'http://grass.osgeo.org/grass64/manuals/' + self.grassName + ".html"
return 'http://grass.osgeo.org/grass64/manuals/' + self.grassName + ".html"

def getParameterDescriptions(self):
descs = {}
Expand Down Expand Up @@ -293,8 +293,8 @@ def processAlgorithm(self, progress):
command+= (" > " + out.value)
else:
command+=(" " + out.name + "=\"" + out.value + "\"");
elif not isinstance(out, OutputHTML):
#html files are not generated by GRASS, only by SEXTANTE to decorate grass output, so we skip them
elif not isinstance(out, OutputHTML):
#html files are not generated by GRASS, only by SEXTANTE to decorate grass output, so we skip them
#An output name to make sure it is unique if the session uses this algorithm several times
uniqueOutputName = out.name + uniqueSufix
command += (" " + out.name + "=" + uniqueOutputName)
Expand Down Expand Up @@ -358,7 +358,7 @@ def postProcessResults(self):

def exportVectorLayer(self, orgFilename):
#TODO: improve this. We are now exporting if it is not a shapefile,
#but the functionality of v.in.ogr could be used for this.
#but the functionality of v.in.ogr could be used for this.
#We also export if there is a selection
if not os.path.exists(orgFilename) or not orgFilename.endswith("shp"):
layer = QGisLayers.getObjectFromUri(orgFilename, False)
Expand Down Expand Up @@ -427,12 +427,12 @@ def getTempFilename(self):

def commandLineName(self):
return "grass:" + self.name[:self.name.find(" ")]

def checkBeforeOpeningParametersDialog(self):
msg = GrassUtils.checkGrassIsInstalled()
if msg is not None:
html = ("<p>This algorithm requires GRASS to be run."
"Unfortunately, it seems that GRASS is not installed in your system, or it is not correctly configured to be used from QGIS</p>")
if msg is not None:
html = ("<p>This algorithm requires GRASS to be run."
"Unfortunately, it seems that GRASS is not installed in your system, or it is not correctly configured to be used from QGIS</p>")
html += '<p><a href= "http://docs.qgis.org/html/en/docs/user_manual/sextante/3rdParty.html">Click here</a> to know more about how to install and configure GRASS to be used with SEXTANTE</p>'
return html

Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/grass/GrassAlgorithmProvider.py
Expand Up @@ -46,13 +46,13 @@ def initializeSettings(self):
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_FOLDER, "GRASS folder", GrassUtils.grassPath()))
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_WIN_SHELL, "Msys folder", GrassUtils.grassWinShell()))
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_LOG_COMMANDS, "Log execution commands", False))
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_LOG_CONSOLE, "Log console output", False))
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_LOG_CONSOLE, "Log console output", False))

def unload(self):
AlgorithmProvider.unload(self)
if SextanteUtils.isWindows() or SextanteUtils.isMac():
SextanteConfig.removeSetting(GrassUtils.GRASS_FOLDER)
SextanteConfig.removeSetting(GrassUtils.GRASS_WIN_SHELL)
SextanteConfig.removeSetting(GrassUtils.GRASS_WIN_SHELL)
SextanteConfig.removeSetting(GrassUtils.GRASS_LOG_COMMANDS)
SextanteConfig.removeSetting(GrassUtils.GRASS_LOG_CONSOLE)

Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/grass/GrassUtils.py
Expand Up @@ -43,7 +43,7 @@ class GrassUtils:
GRASS_REGION_XMAX = "GRASS_REGION_XMAX"
GRASS_REGION_YMAX = "GRASS_REGION_YMAX"
GRASS_REGION_CELLSIZE = "GRASS_REGION_CELLSIZE"
GRASS_FOLDER = "GRASS_FOLDER"
GRASS_FOLDER = "GRASS_FOLDER"
GRASS_WIN_SHELL = "GRASS_WIN_SHELL"
GRASS_LOG_COMMANDS = "GRASS_LOG_COMMANDS"
GRASS_LOG_CONSOLE = "GRASS_LOG_CONSOLE"
Expand Down Expand Up @@ -327,7 +327,7 @@ def checkGrassIsInstalled(ignoreRegistrySettings=False):

settings = QSettings()
GRASS_INSTALLED = "/SextanteQGIS/GrassInstalled"
if not ignoreRegistrySettings:
if not ignoreRegistrySettings:
if settings.contains(GRASS_INSTALLED):
return

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/gui/MissingDependencyDialog.py
Expand Up @@ -40,7 +40,7 @@ def setupUi(self):
layout = QVBoxLayout()
webView = QtWebKit.QWebView()
webView.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks)
webView.connect(webView, SIGNAL("linkClicked(const QUrl&)"), self.linkClicked)
webView.connect(webView, SIGNAL("linkClicked(const QUrl&)"), self.linkClicked)
webView.setHtml(self.msg)
closeButton = QtGui.QPushButton()
closeButton.setText("Close")
Expand Down
12 changes: 6 additions & 6 deletions python/plugins/sextante/modeler/ModelerParametersDialog.py
Expand Up @@ -651,7 +651,7 @@ def setParamTableFieldValue(self, param, widget):
idx = widget.findText(widget.currentText())
if idx < 0:
name = self.getSafeNameForHarcodedParameter(param)
value = AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, name)
value = AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, name)
s = str(widget.currentText()).strip()
if s == "":
if param.optional:
Expand All @@ -669,21 +669,21 @@ def setParamTableFieldValue(self, param, widget):
return True

def setParamStringValue(self, param, widget):
if param.multiline:
if param.multiline:
name = self.getSafeNameForHarcodedParameter(param)
paramValue = AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, name)
value = widget.getValue()
option = widget.getOption()
if option == MultilineTextPanel.USE_TEXT:
if option == MultilineTextPanel.USE_TEXT:
if value == "":
if param.optional:
self.params[param.name] = None
return True
return True
else:
return False
else:
else:
self.values[name] = value

self.params[param.name] = paramValue
else:
self.params[param.name] = value
Expand Down
8 changes: 4 additions & 4 deletions python/plugins/sextante/modeler/SaveAsPythonScriptAction.py
Expand Up @@ -46,7 +46,7 @@ def execute(self):
if filename:
if not filename.endswith(".py"):
filename += ".py"
text = self.translateToPythonCode(self.alg)
text = self.translateToPythonCode(self.alg)
try:
fout = open(filename, "w")
fout.write(text)
Expand All @@ -57,8 +57,8 @@ def execute(self):
QMessageBox.warning(self,
self.tr("I/O error"),
self.tr("Unable to save edits. Reason:\n %1").arg(unicode(sys.exc_info()[1]))
)
)

def translateToPythonCode(self, model):
s = ["##" + model.name + "=name"]
for param in model.parameters:
Expand Down Expand Up @@ -113,4 +113,4 @@ def translateToPythonCode(self, model):
i += 1
s += multiple
s.append(str(runline + ")"))
return "\n".join(s)
return "\n".join(s)
10 changes: 5 additions & 5 deletions python/plugins/sextante/parameters/ParameterTableField.py
Expand Up @@ -43,23 +43,23 @@ def getValueAsCommandLineParameter(self):

def getAsScriptCode(self):
return "##" + self.name + "=field " + str(self.parent)

def setValue(self, field):
if field is None:
return self.optional
elif len(field) > 0:
elif len(field) > 0:
self.value = str(field)
else:
return self.optional
return self.optional
return True

def serialize(self):
return self.__module__.split(".")[-1] + "|" + self.name + "|" + self.description +\
"|" + str(self.parent) + "|" + str(self.datatype)

def deserialize(self, s):
tokens = s.split("|")
return ParameterTableField(tokens[1], tokens[2], tokens[3], int(tokens[4]), tokens[5] == str(True))
tokens = s.split("|")
return ParameterTableField(tokens[1], tokens[2], tokens[3], int(tokens[4]), tokens[5] == str(True))

def __str__(self):
return self.name + " <" + self.__module__.split(".")[-1] +" from " + self.parent + ">"
6 changes: 3 additions & 3 deletions python/plugins/sextante/saga/SagaAlgorithm.py
Expand Up @@ -358,9 +358,9 @@ def exportRasterLayer(self, layer):

def checkBeforeOpeningParametersDialog(self):
msg = SagaUtils.checkSagaIsInstalled()
if msg is not None:
html = ("<p>This algorithm requires SAGA to be run."
"Unfortunately, it seems that SAGA is not installed in your system, or it is not correctly configured to be used from QGIS</p>")
if msg is not None:
html = ("<p>This algorithm requires SAGA to be run."
"Unfortunately, it seems that SAGA is not installed in your system, or it is not correctly configured to be used from QGIS</p>")
html += '<p><a href= "http://docs.qgis.org/html/en/docs/user_manual/sextante/3rdParty.html">Click here</a> to know more about how to install and configure SAGA to be used with SEXTANTE</p>'
return html

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/saga/SagaUtils.py
Expand Up @@ -137,7 +137,7 @@ def checkSagaIsInstalled(ignoreRegistrySettings=False):

settings = QSettings()
SAGA_INSTALLED = "/SextanteQGIS/SagaInstalled"
if not ignoreRegistrySettings:
if not ignoreRegistrySettings:
if settings.contains(SAGA_INSTALLED):
return

Expand Down
18 changes: 9 additions & 9 deletions python/plugins/sextante/tests/GdalTest.py
Expand Up @@ -34,39 +34,39 @@
from sextante.core.SextanteUtils import SextanteUtils

class GdalTest(unittest.TestCase):

def test_gdalogrsieve(self):
outputs=sextante.runalg("gdalogr:sieve",raster(),2,0,None)
output=outputs['dst_filename']
self.assertTrue(os.path.isfile(output))
dataset=gdal.Open(output, GA_ReadOnly)
strhash=hash(str(dataset.ReadAsArray(0).tolist()))
self.assertEqual(strhash,-1353696889)

def test_gdalogrsieveWithUnsupportedOutputFormat(self):
outputs=sextante.runalg("gdalogr:sieve",raster(),2,0, SextanteUtils.getTempFilename("img"))
output=outputs['dst_filename']
self.assertTrue(os.path.isfile(output))
dataset=gdal.Open(output, GA_ReadOnly)
strhash=hash(str(dataset.ReadAsArray(0).tolist()))
self.assertEqual(strhash,-1353696889)

def test_gdalogrwarpreproject(self):
outputs=sextante.runalg("gdalogr:warpreproject",raster(),"EPSG:23030","EPSG:4326",0,0,"",None)
output=outputs['OUTPUT']
self.assertTrue(os.path.isfile(output))
dataset=gdal.Open(output, GA_ReadOnly)
strhash=hash(str(dataset.ReadAsArray(0).tolist()))
self.assertEqual(strhash,-2021328784)
self.assertEqual(strhash,-2021328784)

def test_gdalogrmerge(self):
outputs=sextante.runalg("gdalogr:merge",raster(),False,False,None)
output=outputs['OUTPUT']
self.assertTrue(os.path.isfile(output))
dataset=gdal.Open(output, GA_ReadOnly)
strhash=hash(str(dataset.ReadAsArray(0).tolist()))
self.assertEqual(strhash,-1353696889)

def test_gdalogrogr2ogr(self):
outputs=sextante.runalg("gdalogr:ogr2ogr",union(),3,"",None)
output=outputs['OUTPUT_LAYER']
Expand All @@ -86,8 +86,8 @@ def test_gdalogrogr2ogr(self):
values=[str(attr.toString()) for attr in attrs]
self.assertEqual(expectedvalues, values)
wkt='POLYGON((270807.08580285 4458940.1594565,270798.42294527 4458914.62661676,270780.81854858 4458914.21983449,270763.52289518 4458920.715993,270760.3449542 4458926.6570575,270763.78234766 4458958.22561242,270794.30290024 4458942.16424502,270807.08580285 4458940.1594565))'
self.assertEqual(wkt, str(feature.geometry().exportToWkt()))
self.assertEqual(wkt, str(feature.geometry().exportToWkt()))

def test_gdalogrogr2ogrWrongExtension(self):
outputs=sextante.runalg("gdalogr:ogr2ogr",union(),3,"",SextanteUtils.getTempFilename("wrongext"))
output=outputs['OUTPUT_LAYER']
Expand All @@ -107,7 +107,7 @@ def test_gdalogrogr2ogrWrongExtension(self):
values=[str(attr.toString()) for attr in attrs]
self.assertEqual(expectedvalues, values)
wkt='POLYGON((270807.08580285 4458940.1594565,270798.42294527 4458914.62661676,270780.81854858 4458914.21983449,270763.52289518 4458920.715993,270760.3449542 4458926.6570575,270763.78234766 4458958.22561242,270794.30290024 4458942.16424502,270807.08580285 4458940.1594565))'
self.assertEqual(wkt, str(feature.geometry().exportToWkt()))
self.assertEqual(wkt, str(feature.geometry().exportToWkt()))

def suite():
suite = unittest.makeSuite(GdalTest, 'test')
Expand Down

0 comments on commit a51fd5f

Please sign in to comment.