Skip to content

Commit

Permalink
[Processing] Add shortHelp for Scripts, Models and R
Browse files Browse the repository at this point in the history
And enhance getParameterDescriptions
  • Loading branch information
rldhont committed May 28, 2016
1 parent 62cb55a commit 7d7467f
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 12 deletions.
31 changes: 25 additions & 6 deletions python/plugins/processing/algs/r/RAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,15 +431,34 @@ def help(self):
else:
return False, None

def shortHelp(self):
if self.descriptionFile is None:
return None
helpFile = unicode(self.descriptionFile) + '.help'
if os.path.exists(helpFile):
with open(helpFile) as f:
try:
descriptions = json.load(f)
if 'ALG_DESC' in descriptions:
return self._formatHelp(unicode(descriptions['ALG_DESC']))
except:
return None
return None

def getParameterDescriptions(self):
descs = {}
helpfile = unicode(self.descriptionFile) + '.help'
if os.path.exists(helpfile):
if self.descriptionFile is None:
return descs
helpFile = unicode(self.descriptionFile) + '.help'
if os.path.exists(helpFile):
with open(helpFile) as f:
descriptions = json.load(f)
for param in self.parameters:
if param.name in descriptions:
descs[param.name] = unicode(descriptions[param.name])
try:
descriptions = json.load(f)
for param in self.parameters:
if param.name in descriptions:
descs[param.name] = unicode(descriptions[param.name])
except:
return None
return descs

def checkBeforeOpeningParametersDialog(self):
Expand Down
5 changes: 5 additions & 0 deletions python/plugins/processing/modeler/ModelerAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,11 @@ def help(self):
except:
return False, None

def shortHelp(self):
if 'ALG_DESC' in self.helpContent:
return self._formatHelp(unicode(self.helpContent['ALG_DESC']))
return None

def getParameterDescriptions(self):
descs = {}
descriptions = self.helpContent
Expand Down
31 changes: 25 additions & 6 deletions python/plugins/processing/script/ScriptAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,13 +331,32 @@ def help(self):
else:
return False, None

def shortHelp(self):
if self.descriptionFile is None:
return None
helpFile = unicode(self.descriptionFile) + '.help'
if os.path.exists(helpFile):
with open(helpFile) as f:
try:
descriptions = json.load(f)
if 'ALG_DESC' in descriptions:
return self._formatHelp(unicode(descriptions['ALG_DESC']))
except:
return None
return None

def getParameterDescriptions(self):
descs = {}
helpfile = unicode(self.descriptionFile) + '.help'
if os.path.exists(helpfile):
if self.descriptionFile is None:
return descs
helpFile = unicode(self.descriptionFile) + '.help'
if os.path.exists(helpFile):
with open(helpFile) as f:
descriptions = json.load(f)
for param in self.parameters:
if param.name in descriptions:
descs[param.name] = unicode(descriptions[param.name])
try:
descriptions = json.load(f)
for param in self.parameters:
if param.name in descriptions:
descs[param.name] = unicode(descriptions[param.name])
except:
return None
return descs

0 comments on commit 7d7467f

Please sign in to comment.