5757from .dinftranslimaccum_multi import DinfTransLimAccumMulti
5858from .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
6164class 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 ))))
0 commit comments