summaryrefslogtreecommitdiffstats
path: root/qtip/cli/utils.py
diff options
context:
space:
mode:
authorTaseer <taseer94@gmail.com>2017-03-13 21:13:45 +0500
committerYujun Zhang <zhang.yujunz@zte.com.cn>2017-03-16 15:57:14 +0000
commit638398e593ab95b8e280a3dafd9e1258dd5560e0 (patch)
tree5510f9078ebd2fb882ec6a517a705ca734dee9e0 /qtip/cli/utils.py
parentaf798ce161d0a074823344fafb4984cc6f35ceec (diff)
Implement 'show' command.
- Render the description via templates JIRA: QTIP-205 Change-Id: I10523f85f80350e901a4a701bb65ca4833f8ff7c Signed-off-by: Taseer Ahmed <taseer94@gmail.com> (cherry picked from commit bb5af4b9be1325b61c7f80e71c7d50892ae22956)
Diffstat (limited to 'qtip/cli/utils.py')
-rw-r--r--qtip/cli/utils.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/qtip/cli/utils.py b/qtip/cli/utils.py
index 844d4f34..a7473236 100644
--- a/qtip/cli/utils.py
+++ b/qtip/cli/utils.py
@@ -7,6 +7,9 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+from jinja2 import Environment
+from jinja2 import FileSystemLoader
+from os import path
from prettytable import PrettyTable
@@ -16,3 +19,13 @@ def table(name, components):
table.align[name] = 'l'
[table.add_row([component['name'][0:-5]]) for component in components]
return table
+
+
+def render(name, var_dict):
+ """ Get the templates to render for specific component """
+ tmpl_path = path.join(path.dirname(__file__), 'templates')
+ tmpl_loader = FileSystemLoader(tmpl_path)
+ env = Environment(loader=tmpl_loader)
+ template = env.get_template('{}.j2'.format(name))
+ result = template.render(var_dict)
+ return result