From 59b1d8d0cc0df52906ff5a947aadc1ce0ff0a5b8 Mon Sep 17 00:00:00 2001 From: Victor Olaya Date: Sat, 12 Jan 2013 12:42:53 +0100 Subject: [PATCH] modified grass postprocessing and edited grass description --- .../grass/description/r.neighbors.txt | 6 +-- .../sextante/grass/description/r.quant.txt | 2 +- .../sextante/grass/description/r.quantile.txt | 6 +-- .../grass/ext/HtmlReportPostProcessor.py | 37 +++++++++++++++++++ python/plugins/sextante/grass/ext/r_coin.py | 14 ++----- python/plugins/sextante/grass/ext/r_covar.py | 15 +++----- .../plugins/sextante/grass/ext/r_describe.py | 13 ++----- python/plugins/sextante/grass/ext/r_info.py | 13 ++----- .../plugins/sextante/grass/ext/r_quantile.py | 29 +++++++++++++++ .../sextante/grass/ext/r_regression_line.py | 14 ++----- python/plugins/sextante/grass/ext/v_class.py | 13 ++----- python/plugins/sextante/grass/ext/v_info.py | 13 ++----- python/plugins/sextante/grass/ext/v_normal.py | 14 ++----- python/plugins/sextante/grass/ext/v_report.py | 13 ++----- python/plugins/sextante/grass/ext/v_univar.py | 14 ++----- 15 files changed, 108 insertions(+), 108 deletions(-) create mode 100644 python/plugins/sextante/grass/ext/HtmlReportPostProcessor.py create mode 100644 python/plugins/sextante/grass/ext/r_quantile.py diff --git a/python/plugins/sextante/grass/description/r.neighbors.txt b/python/plugins/sextante/grass/description/r.neighbors.txt index 5d7017ebee5..e4bd5379d04 100644 --- a/python/plugins/sextante/grass/description/r.neighbors.txt +++ b/python/plugins/sextante/grass/description/r.neighbors.txt @@ -1,10 +1,10 @@ r.neighbors r.neighbors - Makes each cell category value a function of the category values assigned to the cells around it, and stores new cell values in an output raster map layer. Raster (r.*) -ParameterRaster|input|Name of input raster map|False +ParameterRaster|input|Input raster layer|False ParameterSelection|method|Neighborhood operation|average;median;mode;minimum;maximum;stddev;sum;variance;diversity;interspersion -ParameterNumber|size|Neighborhood size|1.0|None|3 +ParameterNumber|size|Neighborhood size|1|None|3 ParameterBoolean|-c|Use circular neighborhood|False *ParameterBoolean|-a|Do not align output with the input|False *ParameterFile|weight|File containing weights|False -OutputRaster|output|Name for output raster map +OutputRaster|output|Output layer diff --git a/python/plugins/sextante/grass/description/r.quant.txt b/python/plugins/sextante/grass/description/r.quant.txt index a91f772a638..eef142a73f0 100644 --- a/python/plugins/sextante/grass/description/r.quant.txt +++ b/python/plugins/sextante/grass/description/r.quant.txt @@ -6,4 +6,4 @@ ParameterRaster|basemap|Base map to take quant rules from|False ParameterRange|fprange|Floating point range: dmin,dmax|0,1 ParameterRange|range|Integer range: min,max|1,255 ParameterBoolean|-t|Truncate floating point data|False -ParameterBoolean|-r|Round floating point data|False +ParameterBoolean|-r|Round floating point data|False \ No newline at end of file diff --git a/python/plugins/sextante/grass/description/r.quantile.txt b/python/plugins/sextante/grass/description/r.quantile.txt index 602f807f648..c8bf86f44f2 100644 --- a/python/plugins/sextante/grass/description/r.quantile.txt +++ b/python/plugins/sextante/grass/description/r.quantile.txt @@ -2,6 +2,6 @@ r.quantile r.quantile - Compute quantiles using two passes. Raster (r.*) ParameterRaster|input|Name of input raster map|False -ParameterNumber|quantiles|Number of quantiles|2.0|None|4 -ParameterString|percentiles|List of percentiles| -ParameterBoolean|-r|Generate recode rules based on quantile-defined intervals|False +ParameterNumber|quantiles|Number of quantiles|2|None|4 +*ParameterBoolean|-r|Generate recode rules based on quantile-defined intervals|False +OutputHTML|html|Output report diff --git a/python/plugins/sextante/grass/ext/HtmlReportPostProcessor.py b/python/plugins/sextante/grass/ext/HtmlReportPostProcessor.py new file mode 100644 index 00000000000..5efb46bf91a --- /dev/null +++ b/python/plugins/sextante/grass/ext/HtmlReportPostProcessor.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- + +""" +*************************************************************************** + HtmlReportPostProcessor.py + --------------------- + Date : December 2012 + Copyright : (C) 2012 by Victor Olaya + Email : volayaf at gmail dot com +*************************************************************************** +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +*************************************************************************** +""" +__author__ = 'Victor Olaya' +__date__ = 'December 2012' +__copyright__ = '(C) 2012, Victor Olaya' +# This will get replaced with a git SHA1 when you do a git archive +__revision__ = '$Format:%H$' + +def postProcessResults(alg): + htmlFile = alg.getOutputFromName('html').value + grassName = alg.grassName + found = False + f = open(htmlFile, "w") + f.write("

" + grassName + "

\n") + for line in alg.consoleOutput: + if found and not line.strip().endswith('exit'): + f.write(line + "
\n") + if grassName in line and not line.startswith("GRASS"): + found = True + f.close() + \ No newline at end of file diff --git a/python/plugins/sextante/grass/ext/r_coin.py b/python/plugins/sextante/grass/ext/r_coin.py index 7086d3c9772..3ea81b9d49a 100644 --- a/python/plugins/sextante/grass/ext/r_coin.py +++ b/python/plugins/sextante/grass/ext/r_coin.py @@ -16,21 +16,15 @@ * * *************************************************************************** """ + __author__ = 'Victor Olaya' __date__ = 'December 2012' __copyright__ = '(C) 2012, Victor Olaya' # This will get replaced with a git SHA1 when you do a git archive __revision__ = '$Format:%H$' +from sextante.grass.ext import HtmlReportPostProcessor + def postProcessResults(alg): - htmlFile = alg.getOutputFromName('html').value - found = False - f = open(htmlFile, "w") - f.write("

r.coin

\n") - for line in alg.consoleOutput: - if found and not line.strip().endswith('exit'): - f.write(line + "
\n") - if 'r.coin' in line: - found = True - f.close() + HtmlReportPostProcessor.postProcessResults(alg) \ No newline at end of file diff --git a/python/plugins/sextante/grass/ext/r_covar.py b/python/plugins/sextante/grass/ext/r_covar.py index 7c6f9085a17..73ff3392252 100644 --- a/python/plugins/sextante/grass/ext/r_covar.py +++ b/python/plugins/sextante/grass/ext/r_covar.py @@ -22,15 +22,10 @@ __copyright__ = '(C) 2012, Victor Olaya' # This will get replaced with a git SHA1 when you do a git archive __revision__ = '$Format:%H$' + +from sextante.grass.ext import HtmlReportPostProcessor + def postProcessResults(alg): - htmlFile = alg.getOutputFromName('html').value - found = False - f = open(htmlFile, "w") - f.write("

r.covar

\n") - for line in alg.consoleOutput: - if found and not line.strip().endswith('exit'): - f.write(line + "
\n") - if 'r.covar' in line: - found = True - f.close() + HtmlReportPostProcessor.postProcessResults(alg) + \ No newline at end of file diff --git a/python/plugins/sextante/grass/ext/r_describe.py b/python/plugins/sextante/grass/ext/r_describe.py index ef44b37db2a..db8a6efc75b 100644 --- a/python/plugins/sextante/grass/ext/r_describe.py +++ b/python/plugins/sextante/grass/ext/r_describe.py @@ -22,15 +22,8 @@ __copyright__ = '(C) 2012, Victor Olaya' # This will get replaced with a git SHA1 when you do a git archive __revision__ = '$Format:%H$' +from sextante.grass.ext import HtmlReportPostProcessor + def postProcessResults(alg): - htmlFile = alg.getOutputFromName('html').value - found = False - f = open(htmlFile, "w") - f.write("

r.describe

\n") - for line in alg.consoleOutput: - if found and not line.strip().endswith('exit'): - f.write(line + "
\n") - if 'r.describe' in line: - found = True - f.close() + HtmlReportPostProcessor.postProcessResults(alg) \ No newline at end of file diff --git a/python/plugins/sextante/grass/ext/r_info.py b/python/plugins/sextante/grass/ext/r_info.py index bda3db8ea6f..55c899453c7 100644 --- a/python/plugins/sextante/grass/ext/r_info.py +++ b/python/plugins/sextante/grass/ext/r_info.py @@ -22,15 +22,8 @@ __copyright__ = '(C) 2012, Victor Olaya' # This will get replaced with a git SHA1 when you do a git archive __revision__ = '$Format:%H$' +from sextante.grass.ext import HtmlReportPostProcessor + def postProcessResults(alg): - htmlFile = alg.getOutputFromName('html').value - found = False - f = open(htmlFile, "w") - f.write("

r.info

\n") - for line in alg.consoleOutput: - if found and not line.strip().endswith('exit'): - f.write(line + "
\n") - if 'r.info' in line: - found = True - f.close() + HtmlReportPostProcessor.postProcessResults(alg) diff --git a/python/plugins/sextante/grass/ext/r_quantile.py b/python/plugins/sextante/grass/ext/r_quantile.py new file mode 100644 index 00000000000..4dc747f17ef --- /dev/null +++ b/python/plugins/sextante/grass/ext/r_quantile.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +""" +*************************************************************************** + r_quantile.py + --------------------- + Date : December 2012 + Copyright : (C) 2012 by Victor Olaya + Email : volayaf at gmail dot com +*************************************************************************** +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +*************************************************************************** +""" +__author__ = 'Victor Olaya' +__date__ = 'December 2012' +__copyright__ = '(C) 2012, Victor Olaya' +# This will get replaced with a git SHA1 when you do a git archive +__revision__ = '$Format:%H$' + +from sextante.grass.ext import HtmlReportPostProcessor + +def postProcessResults(alg): + HtmlReportPostProcessor.postProcessResults(alg) + diff --git a/python/plugins/sextante/grass/ext/r_regression_line.py b/python/plugins/sextante/grass/ext/r_regression_line.py index 3ce127ef01a..3d33f502d1a 100644 --- a/python/plugins/sextante/grass/ext/r_regression_line.py +++ b/python/plugins/sextante/grass/ext/r_regression_line.py @@ -22,15 +22,9 @@ __copyright__ = '(C) 2012, Victor Olaya' # This will get replaced with a git SHA1 when you do a git archive __revision__ = '$Format:%H$' +from sextante.grass.ext import HtmlReportPostProcessor + def postProcessResults(alg): - htmlFile = alg.getOutputFromName('html').value - found = False - f = open(htmlFile, "w") - f.write("

r.regresion.line

\n") - for line in alg.consoleOutput: - if found and not line.strip().endswith('exit'): - f.write(line + "
\n") - if 'r.regression.line' in line: - found = True - f.close() + HtmlReportPostProcessor.postProcessResults(alg) + \ No newline at end of file diff --git a/python/plugins/sextante/grass/ext/v_class.py b/python/plugins/sextante/grass/ext/v_class.py index 5bff67fae8a..6cb3454b373 100644 --- a/python/plugins/sextante/grass/ext/v_class.py +++ b/python/plugins/sextante/grass/ext/v_class.py @@ -22,15 +22,8 @@ __copyright__ = '(C) 2012, Victor Olaya' # This will get replaced with a git SHA1 when you do a git archive __revision__ = '$Format:%H$' +from sextante.grass.ext import HtmlReportPostProcessor + def postProcessResults(alg): - htmlFile = alg.getOutputFromName('html').value - found = False - f = open(htmlFile, "w") - f.write("

v.class

\n") - for line in alg.consoleOutput: - if found and not line.strip().endswith('exit'): - f.write(line + "
\n") - if 'v.class' in line: - found = True - f.close() + HtmlReportPostProcessor.postProcessResults(alg) \ No newline at end of file diff --git a/python/plugins/sextante/grass/ext/v_info.py b/python/plugins/sextante/grass/ext/v_info.py index 4c95a7b0d51..913a961ffd4 100644 --- a/python/plugins/sextante/grass/ext/v_info.py +++ b/python/plugins/sextante/grass/ext/v_info.py @@ -22,15 +22,8 @@ __copyright__ = '(C) 2012, Victor Olaya' # This will get replaced with a git SHA1 when you do a git archive __revision__ = '$Format:%H$' +from sextante.grass.ext import HtmlReportPostProcessor + def postProcessResults(alg): - htmlFile = alg.getOutputFromName('html').value - found = False - f = open(htmlFile, "w") - f.write("

v.info

\n") - for line in alg.consoleOutput: - if found and not line.strip().endswith('exit'): - f.write(line + "
\n") - if 'v.info' in line: - found = True - f.close() + HtmlReportPostProcessor.postProcessResults(alg) diff --git a/python/plugins/sextante/grass/ext/v_normal.py b/python/plugins/sextante/grass/ext/v_normal.py index fd1096b40c5..51ad5f10b2d 100644 --- a/python/plugins/sextante/grass/ext/v_normal.py +++ b/python/plugins/sextante/grass/ext/v_normal.py @@ -22,15 +22,9 @@ __copyright__ = '(C) 2012, Victor Olaya' # This will get replaced with a git SHA1 when you do a git archive __revision__ = '$Format:%H$' +from sextante.grass.ext import HtmlReportPostProcessor + def postProcessResults(alg): - htmlFile = alg.getOutputFromName('html').value - found = False - f = open(htmlFile, "w") - f.write("

v.normal

\n") - for line in alg.consoleOutput: - if found and not line.strip().endswith('exit'): - f.write(line + "
\n") - if 'v.normal' in line: - found = True - f.close() + HtmlReportPostProcessor.postProcessResults(alg) + \ No newline at end of file diff --git a/python/plugins/sextante/grass/ext/v_report.py b/python/plugins/sextante/grass/ext/v_report.py index 6cfeee532f1..d2ed610215a 100644 --- a/python/plugins/sextante/grass/ext/v_report.py +++ b/python/plugins/sextante/grass/ext/v_report.py @@ -22,15 +22,8 @@ __copyright__ = '(C) 2012, Victor Olaya' # This will get replaced with a git SHA1 when you do a git archive __revision__ = '$Format:%H$' +from sextante.grass.ext import HtmlReportPostProcessor + def postProcessResults(alg): - htmlFile = alg.getOutputFromName('html').value - found = False - f = open(htmlFile, "w") - f.write("

v.report

\n") - for line in alg.consoleOutput: - if found and not line.strip().endswith('exit'): - f.write(line + "
\n") - if 'v.report' in line: - found = True - f.close() + HtmlReportPostProcessor.postProcessResults(alg) \ No newline at end of file diff --git a/python/plugins/sextante/grass/ext/v_univar.py b/python/plugins/sextante/grass/ext/v_univar.py index 1973107c25d..d0b13ab8426 100644 --- a/python/plugins/sextante/grass/ext/v_univar.py +++ b/python/plugins/sextante/grass/ext/v_univar.py @@ -22,15 +22,7 @@ __copyright__ = '(C) 2012, Victor Olaya' # This will get replaced with a git SHA1 when you do a git archive __revision__ = '$Format:%H$' +from sextante.grass.ext import HtmlReportPostProcessor + def postProcessResults(alg): - htmlFile = alg.getOutputFromName('html').value - found = False - f = open(htmlFile, "w") - f.write("

v.univar

\n") - for line in alg.consoleOutput: - if found and not line.strip().endswith('exit'): - f.write(line + "
\n") - if 'v.univar' in line: - found = True - f.close() - \ No newline at end of file + HtmlReportPostProcessor.postProcessResults(alg) \ No newline at end of file