summaryrefslogtreecommitdiffstats
path: root/vstf/vstf/controller/reporters/report/html/html_base.py
blob: 270ef3946f550cb25e4caba51daaeec07ca62aca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/python
# -*- coding: utf8 -*-
# author: wly
# date: 2015-09.25
# see license for license details
__version__ = ''' '''

import os
from vstf.common.pyhtml import *


class HtmlBase(object):
    def __init__(self, provider, ofile='text.html'):
        self._page = PyHtml('HtmlBase Text')
        self._ofile = ofile
        self._provider = provider
        self._chapter = 1

    def save(self):
        if self._ofile:
            os.system('rm -rf %s' % self._ofile)
            self._page.output(self._ofile)

    def as_string(self):
        return self._page.as_string()

    def add_table(self, data):
        self._page.add_table(data)

    def add_style(self):
        style = self._provider.get_style()
        self._page.add_style(style)

    def create(self, is_save=True):
        self.add_style()
        self.create_story()
        if is_save:
            self.save()
        return self.as_string()

    def create_story(self):
        raise NotImplementedError("abstract HtmlBase")