diff --git a/python/plugins/processing/algs/saga/SagaHelpGenerator.py b/python/plugins/processing/algs/saga/SagaHelpGenerator.py deleted file mode 100644 index 49328f1c1d9..00000000000 --- a/python/plugins/processing/algs/saga/SagaHelpGenerator.py +++ /dev/null @@ -1,212 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - SagaHelpGenerator.py - --------------------- - Date : August 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__ = 'August 2012' -__copyright__ = '(C) 2012, Victor Olaya' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -import os -import saga_api as saga - - -class Library: - def __init__(self, filename): - self.sagalib = saga.CSG_Module_Library(saga.CSG_String(str(filename))) - if not self.sagalib.is_Valid(): - raise ImportError(filename) - self.libname = filename.split(os.sep)[-1].split(".")[0] - if self.libname.startswith("lib"): - self.libname = self.libname[3:] - self.name = self.sagalib.Get_Name().c_str() - self._modules = None - - def modules(self): - if self._modules is not None: - return self._modules - self._modules = list() - for i in range(self.sagalib.Get_Count()): - try: - self._modules.append(Module(self.sagalib, i)) - except ImportError: - pass - return self._modules - - def __del__(self): - self.sagalib.Destroy() - - -class Module: - def __init__(self, lib, i): - self.module = lib.Get_Module(i) - if not self.module: - raise ImportError("Module #%i is invalid" % i) - if self.module.is_Interactive(): - raise ImportError("Ignoring interactive module") - self.name = self.module.Get_Name() - self.grid = self.module.is_Grid() - if self.module.is_Grid(): - self.module = lib.Get_Module_Grid(i) - self.description = self.module.Get_Description() - self.author = self.module.Get_Author() - self._parameters = None - - def parameters(self): - if self._parameters is not None: - return self._parameters - params = list() - params.append(self.module.Get_Parameters()) - for i in range(self.module.Get_Parameters_Count()): - params.append(self.module.Get_Parameters(i)) - self._parameters = list() - for p in params: - for j in range(p.Get_Count()): - try: - self._parameters.append(Parameter(p, j)) - except: - pass - return self._parameters - - -class Parameter: - def __init__(self, params, i): - self.parameter = params.Get_Parameter(i) - self.name = self.parameter.Get_Name() - self.description = self.parameter.Get_Description() - self.typeName = self.parameter.Get_Type_Name() - if self.parameter.is_Output(): - self.typeName = "Output " + self.typeName - if self.parameter.is_Input(): - self.typeName = "Input " + self.typeName - typ = self.parameter.Get_Type() - self.minimum = None - self.maximum = None - if (typ == saga.PARAMETER_TYPE_Int) or \ - (typ == saga.PARAMETER_TYPE_Double) or \ - (typ == saga.PARAMETER_TYPE_Degree) or \ - (typ == saga.PARAMETER_TYPE_Range): - parameterValue = self.parameter.asValue() - if parameterValue.has_Minimum(): - self.minimum = parameterValue.Get_Minimum() - if parameterValue.has_Maximum(): - self.maximum = parameterValue.Get_Maximum() - self.choices = None - if typ == saga.PARAMETER_TYPE_Choice: - parameterChoice = self.parameter.asChoice() - self.choices = [parameterChoice.Get_Item(i) for i in - range(parameterChoice.Get_Count())] - - -def getLibraryPaths(userPath=None): - try: - paths = os.environ['MLB_PATH'].split(':') - except KeyError: - paths = ['/usr/lib/saga/', '/usr/local/lib/saga/'] - noMLBpath = True - if userPath: - paths = [userPath] + paths - print "Looking for libraries in " + ', '.join(paths) - for p in paths: - if os.path.exists(p): - return [os.path.join(p, fn) for fn in os.listdir(p)] - if noMLBpath: - print "Warning: MLB_PATH not set." - return [] - - -def qgisizeString(s): - try: - s = str(s) - s = str.replace(s, "Gridd", "Raster") - s = str.replace(s, "Grid", "Raster") - s = str.replace(s, "gridd", "raster") - s = str.replace(s, "grid", "raster") - except: - # Some unicode characters seem to produce exceptions. - # Just ignore those cases. - pass - return s - - -def writeHTML(path, mod): - docs = unicode() - docs += "