2626
2727__revision__ = '$Format:%H$'
2828
29+ from PyQt4 .QtCore import QCoreApplication
2930import os
3031import re
3132import json
4243 (r"::(\s*\n(\s*\n)*((\s+).*?\n)(((\4).*?\n)|(\s*\n))*)" ,r"<pre>\1</pre>" ),
4344 ("\n +" , "</p><p>" )]
4445
45-
4646def getHtmlFromRstFile (rst ):
4747 if not os .path .exists (rst ):
4848 return None
@@ -54,20 +54,17 @@ def getHtmlFromRstFile(rst):
5454 s = p .sub (replace , s )
5555 return s
5656
57-
5857def getHtmlFromHelpFile (alg , helpFile ):
5958 if not os .path .exists (helpFile ):
6059 return None
6160 try :
6261 with open (helpFile ) as f :
6362 descriptions = json .load (f )
64- return getHtmlFromDescriptionsDict (descriptions )
63+ return getHtmlFromDescriptionsDict (alg , descriptions )
6564 except :
6665 return None
6766
68-
6967def getHtmlFromDescriptionsDict (alg , descriptions ):
70-
7168 s = tr ('<html><body><h2>Algorithm description</h2>\n ' )
7269 s += '<p>' + getDescription (ALG_DESC , descriptions ) + '</p>\n '
7370 s += tr ('<h2>Input parameters</h2>\n ' )
@@ -80,17 +77,16 @@ def getHtmlFromDescriptionsDict(alg, descriptions):
8077 s += '<p>' + getDescription (out .name , descriptions ) + '</p>\n '
8178 s += '<br>'
8279 s += tr ('<p align="right">Algorithm author: %s</p>' ) % getDescription (ALG_CREATOR , descriptions )
83- s += tr ('<p align="right">Help author: %s</p>' ) + getDescription (ALG_HELP_CREATOR , descriptions )
84- s += tr ('<p align="right">Algorithm version: %s</p>' ) + getDescription (ALG_VERSION , descriptions )
80+ s += tr ('<p align="right">Help author: %s</p>' ) % getDescription (ALG_HELP_CREATOR , descriptions )
81+ s += tr ('<p align="right">Algorithm version: %s</p>' ) % getDescription (ALG_VERSION , descriptions )
8582 s += '</body></html>'
8683 return s
8784
88-
8985def getDescription (name , descriptions ):
9086 if name in descriptions :
9187 return unicode (descriptions [name ]).replace ("\n " , "<br>" )
9288 else :
9389 return ''
9490
9591def tr (string ):
96- return QtCore . QCoreApplication .translate ('Help2Html' , string )
92+ return QCoreApplication .translate ('Help2Html' , string )
0 commit comments