diff options
Diffstat (limited to 'vstf/vstf/controller/reporters/report/provider')
3 files changed, 83 insertions, 56 deletions
diff --git a/vstf/vstf/controller/reporters/report/provider/__init__.py b/vstf/vstf/controller/reporters/report/provider/__init__.py index 89dcd4e2..83b8d15d 100755 --- a/vstf/vstf/controller/reporters/report/provider/__init__.py +++ b/vstf/vstf/controller/reporters/report/provider/__init__.py @@ -1,14 +1,8 @@ -# Copyright Huawei Technologies Co., Ltd. 1998-2015. -# All Rights Reserved. +############################################################################## +# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others. # -# Licensed under the Apache License, Version 2.0 (the License); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an AS IS BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## diff --git a/vstf/vstf/controller/reporters/report/provider/html_provider.py b/vstf/vstf/controller/reporters/report/provider/html_provider.py index b0b07432..74c4c593 100755 --- a/vstf/vstf/controller/reporters/report/provider/html_provider.py +++ b/vstf/vstf/controller/reporters/report/provider/html_provider.py @@ -1,63 +1,45 @@ -#!/usr/bin/python -# -*- coding: utf8 -*- -# author: wly -# date: 2015-09-25 -# see license for license details -__version__ = ''' ''' +############################################################################## +# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + import logging LOG = logging.getLogger(__name__) from vstf.controller.settings.html_settings import HtmlSettings -from vstf.controller.settings.data_settings import DataSettings +from vstf.controller.settings.template_settings import TemplateSettings class HtmlProvider(object): - def __init__(self, content, style): - self._content = content + def __init__(self, info, style): + self._info = info self._style = style + @property def get_style(self): + assert "style" in self._style 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"] + @property + def get_context(self): + assert "context" in self._info + return self._info["context"] -def unit_test(): +def main(): 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) + info = TemplateSettings() + provider = HtmlProvider(info.settings, html_settings.settings) + LOG.info(provider.get_style) + LOG.info(provider.get_context) - hprovider = HtmlProvider(data_settings.settings, html_settings.settings) - sprovider = StyleProvider(html_settings.settings) +if __name__ == '__main__': + main()
\ No newline at end of file diff --git a/vstf/vstf/controller/reporters/report/provider/pdf_provider.py b/vstf/vstf/controller/reporters/report/provider/pdf_provider.py new file mode 100755 index 00000000..bc9f0e96 --- /dev/null +++ b/vstf/vstf/controller/reporters/report/provider/pdf_provider.py @@ -0,0 +1,51 @@ +############################################################################## +# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + + +__version__ = ''' ''' +import logging + +LOG = logging.getLogger(__name__) +from vstf.controller.settings.template_settings import TemplateSettings + + +class PdfProvider(object): + def __init__(self, info): + self._info = info + + @property + def get_theme(self): + assert "theme" in self._info + return self._info["theme"] + + @property + def ifcontents(self): + assert "contents" in self._info + assert "enable" in self._info["contents"] + return self._info["contents"]["enable"] + + @property + def get_context(self): + assert "context" in self._info + return self._info["context"] + + +def main(): + from vstf.common.log import setup_logging + setup_logging(level=logging.DEBUG, log_file="/var/log/pdf-provider.log", clevel=logging.INFO) + + info = TemplateSettings() + provider = PdfProvider(info.settings) + LOG.info(provider.get_theme) + LOG.info(provider.ifcontents) + LOG.info(provider.get_context) + +if __name__ == '__main__': + main()
\ No newline at end of file |