Merge "Change PTL informatin in INFO"
[bottlenecks.git] / testsuites / vstf / vstf_scripts / vstf / controller / reporters / report / html / html_base.py
1 ##############################################################################
2 # Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9
10
11 import os
12 import vstf.common.pyhtml as pyhtm
13
14
15 class HtmlBase(object):
16
17     def __init__(self, provider):
18         self._page = pyhtm.PyHtml('Html Text')
19         self._provider = provider
20
21     def save(self, ofile):
22         if ofile:
23             os.system('rm -rf %s' % ofile)
24             self._page.output(ofile)
25
26     def as_string(self):
27         return self._page.as_string()
28
29     def add_table(self, data):
30         if data and zip(*data):
31             self._page.add_table(data)
32
33     def add_style(self):
34         style = self._provider.get_style
35         self._page.add_style(style)
36
37     def create(self, ofile='text.html'):
38         self.add_style()
39         self.create_story()
40         self.save(ofile)
41         return self.as_string()
42
43     def create_story(self):
44         raise NotImplementedError("abstract HtmlBase")