Skip to content
Permalink
Browse files

indentation update

  • Loading branch information
jef-n committed Apr 15, 2013
1 parent cfe43dc commit a51fd5f0cef1ff58be082230b4e3291e67bb4566
Showing with 622 additions and 622 deletions.
  1. +1 −1 python/plugins/sextante/algs/ftools/ConvexHull.py
  2. +1 −1 python/plugins/sextante/algs/ftools/ReprojectLayer.py
  3. +1 −1 python/plugins/sextante/gdal/OgrAlgorithm.py
  4. +17 −17 python/plugins/sextante/gdal/ogr2ogr.py
  5. +8 −8 python/plugins/sextante/grass/GrassAlgorithm.py
  6. +2 −2 python/plugins/sextante/grass/GrassAlgorithmProvider.py
  7. +2 −2 python/plugins/sextante/grass/GrassUtils.py
  8. +1 −1 python/plugins/sextante/gui/MissingDependencyDialog.py
  9. +6 −6 python/plugins/sextante/modeler/ModelerParametersDialog.py
  10. +4 −4 python/plugins/sextante/modeler/SaveAsPythonScriptAction.py
  11. +5 −5 python/plugins/sextante/parameters/ParameterTableField.py
  12. +3 −3 python/plugins/sextante/saga/SagaAlgorithm.py
  13. +1 −1 python/plugins/sextante/saga/SagaUtils.py
  14. +9 −9 python/plugins/sextante/tests/GdalTest.py
  15. +5 −5 python/plugins/sextante/tests/GeoAlgorithmTest.py
  16. +7 −7 python/plugins/sextante/tests/ModelerAlgorithmTest.py
  17. +3 −3 python/plugins/sextante/tests/QgisAlgsTest.py
  18. +1 −1 python/plugins/sextante/tests/SagaTest.py
  19. +2 −2 python/plugins/sextante/tests/ScriptTest.py
  20. +2 −2 python/plugins/sextante/tests/SextanteTests.py
  21. +16 −16 python/plugins/sextante/tests/SextanteToolsTest.py
  22. +4 −4 python/plugins/sextante/tools/vector.py
  23. +2 −2 src/app/qgisappinterface.cpp
  24. +3 −3 src/app/qgsaddtaborgroup.cpp
  25. +1 −1 src/app/qgsaddtaborgroup.h
  26. +2 −2 src/app/qgsattributetabledialog.cpp
  27. +3 −3 src/app/qgsfieldsproperties.cpp
  28. +1 −1 src/core/composer/qgscomposerlabel.cpp
  29. +2 −2 src/core/composer/qgscomposerlegend.cpp
  30. +1 −1 src/core/qgsproject.cpp
  31. +1 −1 src/core/qgsproject.h
  32. +3 −3 src/core/qgsvectorlayer.cpp
  33. +1 −1 src/core/qgsvectorlayerfeatureiterator.cpp
  34. +9 −9 src/core/raster/qgsrasteridentifyresult.cpp
  35. +5 −5 src/core/raster/qgsrasterrange.cpp
  36. +2 −2 src/core/raster/qgsrasterrange.h
  37. +1 −1 src/core/symbology-ng/qgssymbologyv2conversion.cpp
  38. +1 −1 src/gui/attributetable/qgsattributetabledelegate.h
  39. +2 −2 src/gui/attributetable/qgsattributetablefiltermodel.cpp
  40. +1 −1 src/gui/attributetable/qgsattributetablefiltermodel.h
  41. +2 −2 src/gui/attributetable/qgsattributetablemodel.cpp
  42. +39 −39 src/gui/attributetable/qgsattributetableview.cpp
  43. +2 −2 src/gui/attributetable/qgsfeaturelistmodel.cpp
  44. +15 −15 src/gui/attributetable/qgsfeaturelistview.cpp
  45. +1 −1 src/gui/attributetable/qgsfeaturelistview.h
  46. +2 −2 src/gui/attributetable/qgsfeaturelistviewdelegate.cpp
  47. +2 −2 src/gui/attributetable/qgsfeaturemodel.h
  48. +14 −14 src/gui/attributetable/qgsfeatureselectionmodel.cpp
  49. +84 −84 src/gui/attributetable/qgsfeatureselectionmodel.h
  50. +303 −303 src/providers/delimitedtext/qgsdelimitedtextfile.h
  51. +1 −1 src/providers/ogr/qgsogrprovider.cpp
  52. +1 −1 tests/bench/qgsbench.cpp
  53. +1 −1 tests/src/gui/testqgsdualview.cpp
  54. +13 −13 tests/src/python/test_qgsdelimitedtextprovider.py
@@ -71,7 +71,7 @@ def processAlgorithm(self, progress):
GEOS_EXCEPT = True
FEATURE_EXCEPT = True


f = QgsField("value")
f.setType(QVariant.String)
f.setLength(255)
@@ -79,5 +79,5 @@ def processAlgorithm(self, progress):
progress.setPercentage(int(current * total))

del writer

self.crs = targetCrs
@@ -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='(.+)'")
@@ -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,
@@ -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
@@ -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, \
@@ -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 = {}
@@ -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)
@@ -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)
@@ -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

@@ -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)

@@ -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"
@@ -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

@@ -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")
@@ -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:
@@ -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
@@ -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)
@@ -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:
@@ -113,4 +113,4 @@ def translateToPythonCode(self, model):
i += 1
s += multiple
s.append(str(runline + ")"))
return "\n".join(s)
return "\n".join(s)
@@ -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 + ">"
@@ -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

@@ -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

@@ -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']
@@ -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']
@@ -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')

0 comments on commit a51fd5f

Please sign in to comment.
You can’t perform that action at this time.