MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / writeHtmlFile

Function writeHtmlFile

test/scripts/extracttests.py:182–231  ·  view source on GitHub ↗

Write html file for a function name

(nodes, functionName, filename, errorsOnly)

Source from the content-addressed store, hash-verified

180
181
182def writeHtmlFile(nodes, functionName, filename, errorsOnly):
183 """Write html file for a function name"""
184 fout = open(filename, 'w')
185 fout.write('<html>\n')
186 fout.write('<head>\n')
187 fout.write(' <style type="text/css">\n')
188 fout.write(' body { font-size: 0.8em }\n')
189 fout.write(
190 ' th { background-color: #A3C159; text-transform: uppercase }\n')
191 fout.write(' td { background-color: white; vertical-align: text-top }\n')
192 fout.write(' pre { background-color: #EEEEEE }\n')
193 fout.write(' </style>\n')
194 fout.write('</head>\n')
195 fout.write('<body>\n')
196
197 fout.write('<a href="index.htm">Home</a> -- ')
198 if errorsOnly:
199 fout.write('<a href="all-' + functionName + '.htm">All test cases</a>')
200 else:
201 fout.write(
202 '<a href="errors-' + functionName + '.htm">Error test cases</a>')
203 fout.write('<br><br>')
204
205 testclass = None
206 num = 0
207 for node in nodes:
208 if errorsOnly and node['expected'] == '':
209 continue
210 if trimname(node['functionName']) == functionName:
211 num = num + 1
212
213 if not testclass:
214 testclass = node['testclass']
215 fout.write(
216 '<h1>' + node['testclass'] + '::' + functionName + '</h1>')
217 fout.write('<table border="0" cellspacing="0">\n')
218 fout.write(
219 ' <tr><th>Nr</th><th>Code</th><th>Expected</th></tr>\n')
220
221 fout.write(' <tr><td>' + str(num) + '</td>')
222 fout.write('<td><pre>' + strtoxml(
223 node['code']).replace('\\n', '\n') + '</pre></td>')
224 fout.write(
225 '<td>' + strtoxml(node['expected']).replace('\\n', '<br>') + '</td>')
226 fout.write('</tr>\n')
227
228 if testclass is not None:
229 fout.write('</table>\n')
230 fout.write('</body></html>\n')
231 fout.close()
232
233
234if len(sys.argv) <= 1 or '--help' in sys.argv:

Callers 1

extracttests.pyFile · 0.85

Calls 6

trimnameFunction · 0.85
strFunction · 0.85
strtoxmlFunction · 0.85
writeMethod · 0.45
replaceMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected