Skip to content

Commit 7866bda

Browse files
committed
[processing] remove obsolete TauDEM multifile stuff
1 parent 3bfd998 commit 7866bda

55 files changed

Lines changed: 54 additions & 1395 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

python/plugins/processing/algs/taudem/TauDEMAlgorithm.py

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
__revision__ = '$Format:%H$'
2727

2828
import os
29-
from qgis.PyQt.QtCore import QCoreApplication
29+
3030
from qgis.PyQt.QtGui import QIcon
3131

3232
from processing.core.GeoAlgorithm import GeoAlgorithm
@@ -45,6 +45,9 @@
4545

4646
from .TauDEMUtils import TauDEMUtils
4747

48+
pluginPath = os.path.normpath(os.path.join(
49+
os.path.split(os.path.dirname(__file__))[0], os.pardir))
50+
4851

4952
class TauDEMAlgorithm(GeoAlgorithm):
5053

@@ -59,34 +62,33 @@ def getCopy(self):
5962
return newone
6063

6164
def getIcon(self):
62-
return QIcon(os.path.dirname(__file__) + '/../../images/taudem.svg')
65+
return QIcon(os.path.join(pluginPath, 'images', 'taudem.svg'))
6366

6467
def defineCharacteristicsFromFile(self):
65-
lines = open(self.descriptionFile)
66-
line = lines.readline().strip('\n').strip()
67-
self.name = line
68-
self.i18n_name = QCoreApplication.translate("TAUDEMAlgorithm", line)
69-
line = lines.readline().strip('\n').strip()
70-
self.cmdName = line
71-
line = lines.readline().strip('\n').strip()
72-
self.group = line
73-
self.i18n_group = QCoreApplication.translate("TAUDEMAlgorithm", line)
74-
75-
line = lines.readline().strip('\n').strip()
76-
while line != '':
77-
try:
78-
line = line.strip('\n').strip()
79-
if line.startswith('Parameter'):
80-
param = getParameterFromString(line)
81-
self.addParameter(param)
82-
else:
83-
self.addOutput(getOutputFromString(line))
84-
line = lines.readline().strip('\n').strip()
85-
except Exception as e:
86-
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
87-
self.tr('Could not load TauDEM algorithm: %s\n%s' % (self.descriptionFile, line)))
88-
raise e
89-
lines.close()
68+
with codecs.open(self.descriptionFile, 'utf-8') as f:
69+
line = f.readline().strip('\n').strip()
70+
self.name = line
71+
self.i18n_name = self.tr(line)
72+
line = f.readline().strip('\n').strip()
73+
self.cmdName = line
74+
line = f.readline().strip('\n').strip()
75+
self.group = line
76+
self.i18n_group = self.tr(line)
77+
78+
line = f.readline().strip('\n').strip()
79+
while line != '':
80+
try:
81+
line = line.strip('\n').strip()
82+
if line.startswith('Parameter'):
83+
param = getParameterFromString(line)
84+
self.addParameter(param)
85+
else:
86+
self.addOutput(getOutputFromString(line))
87+
line = f.readline().strip('\n').strip()
88+
except Exception as e:
89+
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
90+
self.tr('Could not load TauDEM algorithm: {}\n{}'.format(self.descriptionFile, line)))
91+
raise e
9092

9193
def processAlgorithm(self, progress):
9294
commands = []

python/plugins/processing/algs/taudem/TauDEMAlgorithmProvider.py

Lines changed: 23 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
from .dinftranslimaccum_multi import DinfTransLimAccumMulti
5858
from .dinftranslimaccum2_multi import DinfTransLimAccum2Multi
5959

60+
pluginPath = os.path.normpath(os.path.join(
61+
os.path.split(os.path.dirname(__file__))[0], os.pardir))
62+
6063

6164
class TauDEMAlgorithmProvider(AlgorithmProvider):
6265

@@ -71,7 +74,7 @@ def getName(self):
7174
return 'taudem'
7275

7376
def getIcon(self):
74-
return QIcon(os.path.dirname(__file__) + '/../../images/taudem.svg')
77+
return QIcon(os.path.join(pluginPath, 'images', 'taudem.svg'))
7578

7679
def initializeSettings(self):
7780
AlgorithmProvider.initializeSettings(self)
@@ -80,16 +83,6 @@ def initializeSettings(self):
8083
TauDEMUtils.TAUDEM_FOLDER,
8184
self.tr('TauDEM command line tools folder'),
8285
TauDEMUtils.taudemPath(), valuetype=Setting.FOLDER))
83-
ProcessingConfig.addSetting(Setting(self.getDescription(),
84-
TauDEMUtils.TAUDEM_MULTIFILE_FOLDER,
85-
self.tr('TauDEM multifile command line tools folder'),
86-
TauDEMUtils.taudemMultifilePath(), valuetype=Setting.FOLDER))
87-
ProcessingConfig.addSetting(Setting(self.getDescription(),
88-
TauDEMUtils.TAUDEM_USE_SINGLEFILE,
89-
self.tr('Enable singlefile TauDEM tools'), True))
90-
ProcessingConfig.addSetting(Setting(self.getDescription(),
91-
TauDEMUtils.TAUDEM_USE_MULTIFILE,
92-
self.tr('Enable multifile TauDEM tools'), False))
9386
ProcessingConfig.addSetting(Setting(self.getDescription(),
9487
TauDEMUtils.MPIEXEC_FOLDER,
9588
self.tr('MPICH2/OpenMPI bin directory'),
@@ -102,63 +95,36 @@ def unload(self):
10295
AlgorithmProvider.unload(self)
10396

10497
ProcessingConfig.removeSetting(TauDEMUtils.TAUDEM_FOLDER)
105-
ProcessingConfig.removeSetting(TauDEMUtils.TAUDEM_MULTIFILE_FOLDER)
106-
ProcessingConfig.removeSetting(TauDEMUtils.TAUDEM_USE_SINGLEFILE)
107-
ProcessingConfig.removeSetting(TauDEMUtils.TAUDEM_USE_MULTIFILE)
10898
ProcessingConfig.removeSetting(TauDEMUtils.MPIEXEC_FOLDER)
10999
ProcessingConfig.removeSetting(TauDEMUtils.MPI_PROCESSES)
110100

111101
def _loadAlgorithms(self):
112102
self.algs = []
113-
basePath = TauDEMUtils.taudemDescriptionPath()
114-
115-
if ProcessingConfig.getSetting(TauDEMUtils.TAUDEM_USE_SINGLEFILE):
116-
folder = os.path.join(basePath, 'single')
117-
118-
for descriptionFile in os.listdir(folder):
119-
if descriptionFile.endswith('txt'):
120-
descriptionFile = os.path.join(folder, descriptionFile)
121-
self._algFromDescription(descriptionFile)
122-
123-
self.algs.append(PeukerDouglas())
124-
self.algs.append(SlopeArea())
125-
self.algs.append(LengthArea())
126-
self.algs.append(DropAnalysis())
127-
self.algs.append(DinfDistDown())
128-
self.algs.append(DinfDistUp())
129-
self.algs.append(GridNet())
130-
self.algs.append(DinfTransLimAccum())
131-
self.algs.append(DinfTransLimAccum2())
132-
133-
if ProcessingConfig.getSetting(TauDEMUtils.TAUDEM_USE_MULTIFILE):
134-
folder = os.path.join(basePath, 'multi')
135-
136-
for descriptionFile in os.listdir(folder):
137-
if descriptionFile.endswith('txt'):
138-
descriptionFile = os.path.join(folder, descriptionFile)
139-
self._algFromDescription(descriptionFile, True)
140-
141-
self.algs.append(PeukerDouglasMulti())
142-
self.algs.append(SlopeAreaMulti())
143-
self.algs.append(LengthAreaMulti())
144-
self.algs.append(DropAnalysisMulti())
145-
self.algs.append(DinfDistDownMulti())
146-
self.algs.append(DinfDistUpMulti())
147-
self.algs.append(GridNetMulti())
148-
self.algs.append(DinfTransLimAccumMulti())
149-
self.algs.append(DinfTransLimAccum2Multi())
103+
folder = TauDEMUtils.taudemDescriptionPath()
104+
105+
for descriptionFile in os.listdir(folder):
106+
if descriptionFile.endswith('txt'):
107+
descriptionFile = os.path.join(folder, descriptionFile)
108+
self._algFromDescription(descriptionFile)
109+
110+
self.algs.append(PeukerDouglas())
111+
self.algs.append(SlopeArea())
112+
self.algs.append(LengthArea())
113+
self.algs.append(DropAnalysis())
114+
self.algs.append(DinfDistDown())
115+
self.algs.append(DinfDistUp())
116+
self.algs.append(GridNet())
117+
self.algs.append(DinfTransLimAccum())
118+
self.algs.append(DinfTransLimAccum2())
150119

151120
def _algFromDescription(self, descriptionFile, multifile=False):
152121
try:
153-
if multifile:
154-
alg = TauDEMMultifileAlgorithm(descriptionFile)
155-
else:
156-
alg = TauDEMAlgorithm(descriptionFile)
122+
alg = TauDEMAlgorithm(descriptionFile)
157123
if alg.name.strip() != '':
158124
self.algs.append(alg)
159125
else:
160126
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
161-
self.tr('Could not open TauDEM algorithm: %s' % descriptionFile))
127+
self.tr('Could not open TauDEM algorithm: {}'.format(descriptionFile)))
162128
except Exception as e:
163129
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
164-
self.tr('Could not open TauDEM algorithm %s:\n%s' % (descriptionFile, unicode(e))))
130+
self.tr('Could not open TauDEM algorithm {}:\n{}'.format(descriptionFile, unicode(e))))

python/plugins/processing/algs/taudem/TauDEMMultifileAlgorithm.py

Lines changed: 0 additions & 122 deletions
This file was deleted.

python/plugins/processing/algs/taudem/TauDEMUtils.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,27 +53,11 @@ def taudemPath():
5353

5454
if isMac():
5555
testfolder = os.path.join(QgsApplication.prefixPath(), 'bin')
56-
if os.path.exists(os.path.join(testfolder, 'slopearea')):
56+
if os.path.exists(os.path.join(testfolder, 'pitremove')):
5757
folder = testfolder
5858
else:
5959
testfolder = '/usr/local/bin'
60-
if os.path.exists(os.path.join(testfolder, 'slopearea')):
61-
folder = testfolder
62-
return folder
63-
64-
@staticmethod
65-
def taudemMultifilePath():
66-
folder = ProcessingConfig.getSetting(TauDEMUtils.TAUDEM_MULTIFILE_FOLDER)
67-
if folder is None:
68-
folder = ''
69-
70-
if isMac():
71-
testfolder = os.path.join(QgsApplication.prefixPath(), 'bin')
72-
if os.path.exists(os.path.join(testfolder, 'slopearea')):
73-
folder = testfolder
74-
else:
75-
testfolder = '/usr/local/bin'
76-
if os.path.exists(os.path.join(testfolder, 'slopearea')):
60+
if os.path.exists(os.path.join(testfolder, 'pitremove')):
7761
folder = testfolder
7862
return folder
7963

python/plugins/processing/algs/taudem/description/single/aread8.txt renamed to python/plugins/processing/algs/taudem/description/aread8.txt

File renamed without changes.

python/plugins/processing/algs/taudem/description/single/areadinf.txt renamed to python/plugins/processing/algs/taudem/description/areadinf.txt

File renamed without changes.

python/plugins/processing/algs/taudem/description/single/d8flowdir.txt renamed to python/plugins/processing/algs/taudem/description/d8flowdir.txt

File renamed without changes.

python/plugins/processing/algs/taudem/description/single/d8flowpathextremeup.txt renamed to python/plugins/processing/algs/taudem/description/d8flowpathextremeup.txt

File renamed without changes.

python/plugins/processing/algs/taudem/description/single/d8hdisttostrm.txt renamed to python/plugins/processing/algs/taudem/description/d8hdisttostrm.txt

File renamed without changes.

python/plugins/processing/algs/taudem/description/single/dinfavalanche.txt renamed to python/plugins/processing/algs/taudem/description/dinfavalanche.txt

File renamed without changes.

0 commit comments

Comments
 (0)