blob: b0b074320714748a205bed16645d2a2d92b73504 (
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#!/usr/bin/python
# -*- coding: utf8 -*-
# author: wly
# date: 2015-09-25
# see license for license details
__version__ = ''' '''
import logging
LOG = logging.getLogger(__name__)
from vstf.controller.settings.html_settings import HtmlSettings
from vstf.controller.settings.data_settings import DataSettings
class HtmlProvider(object):
def __init__(self, content, style):
self._content = content
self._style = style
def get_style(self):
return self._style["style"]
def get_subject(self):
return self._content["subject"]
def get_ovs_title(self):
return self._content["ovs"]["title"]
def get_ovs_table(self):
return map(lambda x: list(x), self._content["ovs"]["content"].items())
def get_result_title(self):
return self._content["result"]["title"]
def get_result_table(self, ttype):
result = []
content = self._content["result"]["content"]
if ttype in content:
result.append(content[ttype]["columns"])
result.extend(content[ttype]["data"])
result = map(lambda x: list(x), zip(*result))
return result
class StyleProvider(object):
def __init__(self, style):
self._style = style
def get_style(self):
return self._style["style"]
def unit_test():
from vstf.common.log import setup_logging
setup_logging(level=logging.DEBUG, log_file="/var/log/html-provder.log", clevel=logging.INFO)
html_settings = HtmlSettings()
LOG.info(html_settings.settings)
data_settings = DataSettings()
LOG.info(data_settings.settings)
hprovider = HtmlProvider(data_settings.settings, html_settings.settings)
sprovider = StyleProvider(html_settings.settings)
|