JIRA: BOTTLENECKS-29
[bottlenecks.git] / vstf / vstf / controller / reporters / report / provider / pdf_provider.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 logging
12
13 LOG = logging.getLogger(__name__)
14 from vstf.controller.settings.template_settings import TemplateSettings
15
16
17 class PdfProvider(object):
18     def __init__(self, info):
19         self._info = info
20
21     @property
22     def get_theme(self):
23         assert "theme" in self._info
24         return self._info["theme"]
25
26     @property
27     def ifcontents(self):
28         assert "contents" in self._info
29         assert "enable" in self._info["contents"]
30         return self._info["contents"]["enable"]
31
32     @property
33     def get_context(self):
34         assert "context" in self._info
35         return self._info["context"]
36
37
38 def main():
39     from vstf.common.log import setup_logging
40     setup_logging(level=logging.DEBUG, log_file="/var/log/pdf-provider.log", clevel=logging.INFO)
41
42     info = TemplateSettings()
43     provider = PdfProvider(info.settings)
44     LOG.info(provider.get_theme)
45     LOG.info(provider.ifcontents)
46     LOG.info(provider.get_context)
47
48 if __name__ == '__main__':
49     main()