Skip to content

Commit 8592a7e

Browse files
committed
[Processing] Add shortHelp for Scripts, Models and R
And enhance getParameterDescriptions
1 parent 2c1f2ce commit 8592a7e

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
@@ -434,15 +434,34 @@ def help(self):
434434
else:
435435
return False, None
436436

437+
def shortHelp(self):
438+
if self.descriptionFile is None:
439+
return None
440+
helpFile = unicode(self.descriptionFile) + '.help'
441+
if os.path.exists(helpFile):
442+
with open(helpFile) as f:
443+
try:
444+
descriptions = json.load(f)
445+
if 'ALG_DESC' in descriptions:
446+
return self._formatHelp(unicode(descriptions['ALG_DESC']))
447+
except:
448+
return None
449+
return None
450+
437451
def getParameterDescriptions(self):
438452
descs = {}
439-
helpfile = unicode(self.descriptionFile) + '.help'
440-
if os.path.exists(helpfile):
453+
if self.descriptionFile is None:
454+
return descs
455+
helpFile = unicode(self.descriptionFile) + '.help'
456+
if os.path.exists(helpFile):
441457
with open(helpFile) as f:
442-
descriptions = json.load(f)
443-
for param in self.parameters:
444-
if param.name in descriptions:
445-
descs[param.name] = unicode(descriptions[param.name])
458+
try:
459+
descriptions = json.load(f)
460+
for param in self.parameters:
461+
if param.name in descriptions:
462+
descs[param.name] = unicode(descriptions[param.name])
463+
except:
464+
return None
446465
return descs
447466

448467
def checkBeforeOpeningParametersDialog(self):

python/plugins/processing/modeler/ModelerAlgorithm.py

+5
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,11 @@ def help(self):
544544
except:
545545
return False, None
546546

547+
def shortHelp(self):
548+
if 'ALG_DESC' in self.helpContent:
549+
return self._formatHelp(unicode(self.helpContent['ALG_DESC']))
550+
return None
551+
547552
def getParameterDescriptions(self):
548553
descs = {}
549554
descriptions = self.helpContent

python/plugins/processing/script/ScriptAlgorithm.py

+25-6
Original file line numberDiff line numberDiff line change
@@ -349,13 +349,32 @@ def help(self):
349349
else:
350350
return False, None
351351

352+
def shortHelp(self):
353+
if self.descriptionFile is None:
354+
return None
355+
helpFile = unicode(self.descriptionFile) + '.help'
356+
if os.path.exists(helpFile):
357+
with open(helpFile) as f:
358+
try:
359+
descriptions = json.load(f)
360+
if 'ALG_DESC' in descriptions:
361+
return self._formatHelp(unicode(descriptions['ALG_DESC']))
362+
except:
363+
return None
364+
return None
365+
352366
def getParameterDescriptions(self):
353367
descs = {}
354-
helpfile = unicode(self.descriptionFile) + '.help'
355-
if os.path.exists(helpfile):
368+
if self.descriptionFile is None:
369+
return descs
370+
helpFile = unicode(self.descriptionFile) + '.help'
371+
if os.path.exists(helpFile):
356372
with open(helpFile) as f:
357-
descriptions = json.load(f)
358-
for param in self.parameters:
359-
if param.name in descriptions:
360-
descs[param.name] = unicode(descriptions[param.name])
373+
try:
374+
descriptions = json.load(f)
375+
for param in self.parameters:
376+
if param.name in descriptions:
377+
descs[param.name] = unicode(descriptions[param.name])
378+
except:
379+
return None
361380
return descs

0 commit comments

Comments
 (0)