Skip to content

Commit

Permalink
[processing] some code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
volaya committed Sep 14, 2013
1 parent 1882bbc commit 71c8672
Show file tree
Hide file tree
Showing 16 changed files with 22 additions and 62 deletions.
8 changes: 0 additions & 8 deletions python/plugins/processing/algs/AddTableField.py
Expand Up @@ -25,12 +25,9 @@

from PyQt4.QtCore import *
from PyQt4.QtGui import *

from qgis.core import *

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.tools import dataobjects, vector

from processing.parameters.ParameterVector import ParameterVector
from processing.parameters.ParameterString import ParameterString
from processing.parameters.ParameterNumber import ParameterNumber
Expand All @@ -49,11 +46,6 @@ class AddTableField(GeoAlgorithm):
TYPE_NAMES = ["Integer", "Float", "String"]
TYPES = [QVariant.Int, QVariant.Double, QVariant.String]

#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/../images/qgis.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Add field to attributes table"
self.group = "Vector table tools"
Expand Down
5 changes: 0 additions & 5 deletions python/plugins/processing/algs/AutoincrementalField.py
Expand Up @@ -35,11 +35,6 @@ class AutoincrementalField(GeoAlgorithm):
INPUT = "INPUT"
OUTPUT = "OUTPUT"

#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/../images/toolbox.png")
#===========================================================================

def processAlgorithm(self, progress):
output = self.getOutputFromName(self.OUTPUT)
vlayer = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT))
Expand Down
5 changes: 0 additions & 5 deletions python/plugins/processing/algs/EquivalentNumField.py
Expand Up @@ -37,11 +37,6 @@ class EquivalentNumField(GeoAlgorithm):
OUTPUT = "OUTPUT"
FIELD = "FIELD"

#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/../images/qgis.png")
#===========================================================================

def processAlgorithm(self, progress):
fieldname = self.getParameterValue(self.FIELD)
output = self.getOutputFromName(self.OUTPUT)
Expand Down
5 changes: 0 additions & 5 deletions python/plugins/processing/algs/Explode.py
Expand Up @@ -36,11 +36,6 @@ class Explode(GeoAlgorithm):
INPUT = "INPUT"
OUTPUT = "OUTPUT"

#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/../images/toolbox.png")
#===========================================================================

def processAlgorithm(self, progress):
vlayer = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT))
output = self.getOutputFromName(self.OUTPUT)
Expand Down
11 changes: 3 additions & 8 deletions python/plugins/processing/algs/FieldPyculator.py
Expand Up @@ -5,7 +5,7 @@
FieldPyculator.py
---------------------
Date : August 2012
Copyright : (C) 2012 by Victor Olaya
Copyright : (C) 2012 by Victor Olaya & NextGIS
Email : volayaf at gmail dot com
***************************************************************************
* *
Expand All @@ -17,27 +17,22 @@
***************************************************************************
"""

__author__ = 'Victor Olaya'
__author__ = 'Victor Olaya & NextGIS'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
__copyright__ = '(C) 2012, Victor Olaya & NextGIS'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import sys

from PyQt4.QtCore import *

from qgis.core import *

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.tools import dataobjects, vector
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException

from processing.parameters.ParameterVector import ParameterVector
from processing.parameters.ParameterString import ParameterString
from processing.parameters.ParameterNumber import ParameterNumber
from processing.parameters.ParameterSelection import ParameterSelection

from processing.outputs.OutputVector import OutputVector


Expand Down
4 changes: 0 additions & 4 deletions python/plugins/processing/algs/FieldsCalculator.py
Expand Up @@ -24,17 +24,13 @@
__revision__ = '$Format:%H$'

from PyQt4.QtCore import *

from qgis.core import *

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.tools import dataobjects, vector

from processing.parameters.ParameterVector import ParameterVector
from processing.parameters.ParameterString import ParameterString
from processing.parameters.ParameterNumber import ParameterNumber
from processing.parameters.ParameterSelection import ParameterSelection

from processing.outputs.OutputVector import OutputVector

class FieldsCalculator(GeoAlgorithm):
Expand Down
1 change: 0 additions & 1 deletion python/plugins/processing/algs/JoinAttributes.py
Expand Up @@ -32,7 +32,6 @@
from PyQt4.QtGui import *
from processing.tools import dataobjects, vector


class JoinAttributes(GeoAlgorithm):

OUTPUT_LAYER = "OUTPUT_LAYER"
Expand Down
2 changes: 0 additions & 2 deletions python/plugins/processing/algs/MeanAndStdDevPlot.py
Expand Up @@ -33,7 +33,6 @@
from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.outputs.OutputHTML import OutputHTML
from processing.tools import *
from processing.tools import dataobjects

class MeanAndStdDevPlot(GeoAlgorithm):

Expand All @@ -54,7 +53,6 @@ def processAlgorithm(self, progress):
values = vector.getAttributeValues(layer, namefieldname, meanfieldname, stddevfieldname)
plt.close()


ind = np.arange(len(values[namefieldname]))
width = 0.8
plt.bar(ind, values[meanfieldname], width,
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/PointsFromLines.py
Expand Up @@ -40,8 +40,8 @@ class PointsFromLines(GeoAlgorithm):
OUTPUT_LAYER = "OUTPUT_LAYER"

def defineCharacteristics(self):
self.name = "Get raster values at layer point"
self.group = "Vector geometry tools"
self.name = "Get raster values at line nodes"
self.group = "Vector analysis tools"

self.addParameter(ParameterRaster(self.INPUT_RASTER, "Raster layer"))
self.addParameter(ParameterVector(self.INPUT_VECTOR, "Vector layer", [ParameterVector.VECTOR_TYPE_LINE]))
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/PointsFromPolygons.py
Expand Up @@ -41,8 +41,8 @@ class PointsFromPolygons(GeoAlgorithm):
OUTPUT_LAYER = "OUTPUT_LAYER"

def defineCharacteristics(self):
self.name = "Points from polygons"
self.group = "Vector geometry tools"
self.name = "Get raster values at polygon nodes"
self.group = "Vector analysis tools"

self.addParameter(ParameterRaster(self.INPUT_RASTER, "Raster layer"))
self.addParameter(ParameterVector(self.INPUT_VECTOR, "Vector layer", [ParameterVector.VECTOR_TYPE_POLYGON]))
Expand Down
3 changes: 0 additions & 3 deletions python/plugins/processing/algs/QGISAlgorithmProvider.py
Expand Up @@ -25,9 +25,7 @@
__revision__ = '$Format:%H$'

from PyQt4.QtGui import *

from processing.core.AlgorithmProvider import AlgorithmProvider

from processing.algs.ftools.PointsInPolygon import PointsInPolygon
from processing.algs.ftools.PointsInPolygonUnique import PointsInPolygonUnique
from processing.algs.ftools.PointsInPolygonWeighted import PointsInPolygonWeighted
Expand Down Expand Up @@ -85,7 +83,6 @@
from processing.algs.JoinAttributes import JoinAttributes
from processing.algs.CreateConstantRaster import CreateConstantRaster
from processing.algs.PointsLayerFromTable import PointsLayerFromTable

from processing.algs.PointsDisplacement import PointsDisplacement
from processing.algs.ZonalStatistics import ZonalStatistics
from processing.algs.PointsFromPolygons import PointsFromPolygons
Expand Down
11 changes: 9 additions & 2 deletions python/plugins/processing/grass/GrassAlgorithm.py
Expand Up @@ -16,7 +16,7 @@
* *
***************************************************************************
"""
from processing import interface

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
Expand All @@ -30,6 +30,8 @@
from qgis.core import *
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from processing import interface
from processing.tools.system import isWindows
from processing.outputs.OutputHTML import OutputHTML
from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.parameters.ParameterTable import ParameterTable
Expand All @@ -46,14 +48,19 @@
from processing.core.ProcessingConfig import ProcessingConfig
from processing.tools import dataobjects
from processing.grass.GrassUtils import GrassUtils
from processing.tools.system import *
from processing.parameters.ParameterSelection import ParameterSelection
from processing.core.WrongHelpFileException import WrongHelpFileException
from processing.outputs.OutputFile import OutputFile
from processing.parameters.ParameterExtent import ParameterExtent
from processing.parameters.ParameterNumber import ParameterNumber
from processing.parameters.ParameterString import ParameterString

NUM_EXPORTED = 1

def getNumExportedLayers():
NUM_EXPORTED += 1
return NUM_EXPORTED

class GrassAlgorithm(GeoAlgorithm):

GRASS_OUTPUT_TYPE_PARAMETER = "GRASS_OUTPUT_TYPE_PARAMETER"
Expand Down
6 changes: 0 additions & 6 deletions python/plugins/processing/grass/GrassUtils.py
Expand Up @@ -275,12 +275,6 @@ def executeGrass(commands, progress, outputCommands = None):
ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
return loglines;

@staticmethod
def getGrassVersion():
#I do not know if this should be removed or let the user enter it
#or something like that... This is just a temporary thing
return "6.4.0"

# GRASS session is used to hold the layers already exported or produced in GRASS
# between multiple calls to GRASS algorithms. This way they don't have
# to be loaded multiple times and following algorithms can use the results
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/processing/grass/grass.txt
Expand Up @@ -96,7 +96,7 @@ to tag a parameter as "advanced", just add "*" before its declaration. For insta
ADVANCED OUTPUT PROCESSING
--------------------------

In some cases, it might be interesting to take the console otput from GRASS and
In some cases, it might be interesting to take the console output from GRASS and
extract a part of it for saving or formatting.

Two things can be done about this:
Expand All @@ -108,7 +108,7 @@ Two things can be done about this:
by low hyphens (for instance r_quantile.py for the r.quantile command), and
add a postProcessResults(alg) method. It will be called when the execution of
the GRASS command is finished.
- Creating a text file. Do as above, but adding an otput of type OutputFile.
- Creating a text file. Do as above, but adding an output of type OutputFile.
Since some GRASS commands might use this type of output, and to make sure that
the value of this output is not passed to the GRASS comman when calling it,
the value of this output is not passed to the GRASS command when calling it,
the output has to be named 'outputtext'
6 changes: 2 additions & 4 deletions python/plugins/processing/saga/SagaAlgorithm.py
Expand Up @@ -16,8 +16,6 @@
* *
***************************************************************************
"""
from processing.parameters.ParameterTableField import ParameterTableField

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
Expand Down Expand Up @@ -48,7 +46,7 @@
from processing.tools import dataobjects
from processing.parameters.ParameterNumber import ParameterNumber
from processing.parameters.ParameterSelection import ParameterSelection
from processing.tools import dataobjects
from processing.parameters.ParameterTableField import ParameterTableField
from processing.parameters.ParameterExtent import ParameterExtent
from processing.parameters.ParameterFixedTable import ParameterFixedTable
from processing.core.ProcessingLog import ProcessingLog
Expand Down Expand Up @@ -329,7 +327,7 @@ def processAlgorithm(self, progress):
def preProcessInputs(self):
name = self.commandLineName().replace('.','_')[len('saga:'):]
try:
module = importlib.import_module('processing.grass.ext.' + name)
module = importlib.import_module('processing.saga.ext.' + name)
except ImportError:
return
if hasattr(module, 'preProcessInputs'):
Expand Down
3 changes: 1 addition & 2 deletions python/plugins/processing/tools/system.py
Expand Up @@ -30,7 +30,6 @@
from PyQt4.QtCore import *
from qgis.core import *


def userFolder():
userDir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + "/processing"
if not QDir(userDir).exists():
Expand Down Expand Up @@ -73,7 +72,7 @@ def getTempFilenameInTempFolder(basename):
return filename

def removeInvalidChars(string):
validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:"
validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:."
string = ''.join(c for c in string if c in validChars)
return string

Expand Down

0 comments on commit 71c8672

Please sign in to comment.