Skip to content

Commit 3799f11

Browse files
author
Rado Guzinski
committed
[processing] Search for description files also in the sub-directories of the script/model directory
1 parent 8499b4d commit 3799f11

File tree

3 files changed

+42
-39
lines changed

3 files changed

+42
-39
lines changed

python/plugins/processing/algs/r/RAlgorithmProvider.py

+14-13
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,17 @@ def _loadAlgorithms(self):
8888
def loadFromFolder(self, folder):
8989
if not os.path.exists(folder):
9090
return
91-
for descriptionFile in os.listdir(folder):
92-
if descriptionFile.endswith('rsx'):
93-
try:
94-
fullpath = os.path.join(folder, descriptionFile)
95-
alg = RAlgorithm(fullpath)
96-
if alg.name.strip() != '':
97-
self.algs.append(alg)
98-
except WrongScriptException, e:
99-
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, e.msg)
100-
except Exception, e:
101-
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
102-
'Could not load R script:' + descriptionFile + '\n'
103-
+ unicode(e))
91+
for path, subdirs, files in os.walk(folder):
92+
for descriptionFile in files:
93+
if descriptionFile.endswith('rsx'):
94+
try:
95+
fullpath = os.path.join(path, descriptionFile)
96+
alg = RAlgorithm(fullpath)
97+
if alg.name.strip() != '':
98+
self.algs.append(alg)
99+
except WrongScriptException, e:
100+
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, e.msg)
101+
except Exception, e:
102+
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
103+
'Could not load R script:' + descriptionFile + '\n'
104+
+ unicode(e))

python/plugins/processing/modeler/ModelerAlgorithmProvider.py

+14-13
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,17 @@ def _loadAlgorithms(self):
8080
def loadFromFolder(self, folder):
8181
if not os.path.exists(folder):
8282
return
83-
for descriptionFile in os.listdir(folder):
84-
if descriptionFile.endswith('model'):
85-
try:
86-
alg = ModelerAlgorithm()
87-
fullpath = os.path.join(folder, descriptionFile)
88-
alg.openModel(fullpath)
89-
if alg.name.strip() != '':
90-
alg.provider = self
91-
self.algs.append(alg)
92-
except WrongModelException, e:
93-
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
94-
'Could not load model ' + descriptionFile + '\n'
95-
+ e.msg)
83+
for path, subdirs, files in os.walk(folder):
84+
for descriptionFile in files:
85+
if descriptionFile.endswith('model'):
86+
try:
87+
alg = ModelerAlgorithm()
88+
fullpath = os.path.join(path, descriptionFile)
89+
alg.openModel(fullpath)
90+
if alg.name.strip() != '':
91+
alg.provider = self
92+
self.algs.append(alg)
93+
except WrongModelException, e:
94+
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
95+
'Could not load model ' + descriptionFile + '\n'
96+
+ e.msg)

python/plugins/processing/script/ScriptAlgorithmProvider.py

+14-13
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,17 @@ def _loadAlgorithms(self):
8282
def loadFromFolder(self, folder):
8383
if not os.path.exists(folder):
8484
return
85-
for descriptionFile in os.listdir(folder):
86-
if descriptionFile.endswith('py'):
87-
try:
88-
fullpath = os.path.join(folder, descriptionFile)
89-
alg = ScriptAlgorithm(fullpath)
90-
if alg.name.strip() != '':
91-
self.algs.append(alg)
92-
except WrongScriptException, e:
93-
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, e.msg)
94-
except Exception, e:
95-
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
96-
'Could not load script:' + descriptionFile + '\n'
97-
+ unicode(e))
85+
for path, subdirs, files in os.walk(folder):
86+
for descriptionFile in files:
87+
if descriptionFile.endswith('py'):
88+
try:
89+
fullpath = os.path.join(path, descriptionFile)
90+
alg = ScriptAlgorithm(fullpath)
91+
if alg.name.strip() != '':
92+
self.algs.append(alg)
93+
except WrongScriptException, e:
94+
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, e.msg)
95+
except Exception, e:
96+
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
97+
'Could not load script:' + descriptionFile + '\n'
98+
+ unicode(e))

0 commit comments

Comments
 (0)