Skip to content

Commit 7d7467f

Browse files
committedMay 28, 2016
[Processing] Add shortHelp for Scripts, Models and R
And enhance getParameterDescriptions
1 parent 62cb55a commit 7d7467f

File tree

3 files changed

+55
-12
lines changed

3 files changed

+55
-12
lines changed
 

‎python/plugins/processing/algs/r/RAlgorithm.py

+25-6
Original file line numberDiff line numberDiff line change
@@ -431,15 +431,34 @@ def help(self):
431431
else:
432432
return False, None
433433

434+
def shortHelp(self):
435+
if self.descriptionFile is None:
436+
return None
437+
helpFile = unicode(self.descriptionFile) + '.help'
438+
if os.path.exists(helpFile):
439+
with open(helpFile) as f:
440+
try:
441+
descriptions = json.load(f)
442+
if 'ALG_DESC' in descriptions:
443+
return self._formatHelp(unicode(descriptions['ALG_DESC']))
444+
except:
445+
return None
446+
return None
447+
434448
def getParameterDescriptions(self):
435449
descs = {}
436-
helpfile = unicode(self.descriptionFile) + '.help'
437-
if os.path.exists(helpfile):
450+
if self.descriptionFile is None:
451+
return descs
452+
helpFile = unicode(self.descriptionFile) + '.help'
453+
if os.path.exists(helpFile):
438454
with open(helpFile) as f:
439-
descriptions = json.load(f)
440-
for param in self.parameters:
441-
if param.name in descriptions:
442-
descs[param.name] = unicode(descriptions[param.name])
455+
try:
456+
descriptions = json.load(f)
457+
for param in self.parameters:
458+
if param.name in descriptions:
459+
descs[param.name] = unicode(descriptions[param.name])
460+
except:
461+
return None
443462
return descs
444463

445464
def checkBeforeOpeningParametersDialog(self):

‎python/plugins/processing/modeler/ModelerAlgorithm.py

+5
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,11 @@ def help(self):
533533
except:
534534
return False, None
535535

536+
def shortHelp(self):
537+
if 'ALG_DESC' in self.helpContent:
538+
return self._formatHelp(unicode(self.helpContent['ALG_DESC']))
539+
return None
540+
536541
def getParameterDescriptions(self):
537542
descs = {}
538543
descriptions = self.helpContent

‎python/plugins/processing/script/ScriptAlgorithm.py

+25-6
Original file line numberDiff line numberDiff line change
@@ -331,13 +331,32 @@ def help(self):
331331
else:
332332
return False, None
333333

334+
def shortHelp(self):
335+
if self.descriptionFile is None:
336+
return None
337+
helpFile = unicode(self.descriptionFile) + '.help'
338+
if os.path.exists(helpFile):
339+
with open(helpFile) as f:
340+
try:
341+
descriptions = json.load(f)
342+
if 'ALG_DESC' in descriptions:
343+
return self._formatHelp(unicode(descriptions['ALG_DESC']))
344+
except:
345+
return None
346+
return None
347+
334348
def getParameterDescriptions(self):
335349
descs = {}
336-
helpfile = unicode(self.descriptionFile) + '.help'
337-
if os.path.exists(helpfile):
350+
if self.descriptionFile is None:
351+
return descs
352+
helpFile = unicode(self.descriptionFile) + '.help'
353+
if os.path.exists(helpFile):
338354
with open(helpFile) as f:
339-
descriptions = json.load(f)
340-
for param in self.parameters:
341-
if param.name in descriptions:
342-
descs[param.name] = unicode(descriptions[param.name])
355+
try:
356+
descriptions = json.load(f)
357+
for param in self.parameters:
358+
if param.name in descriptions:
359+
descs[param.name] = unicode(descriptions[param.name])
360+
except:
361+
return None
343362
return descs

0 commit comments

Comments
 (0)
Please sign in to comment.