diff options
author | Taseer <taseer94@gmail.com> | 2017-03-13 21:13:45 +0500 |
---|---|---|
committer | Taseer <taseer94@gmail.com> | 2017-03-14 14:23:31 +0500 |
commit | bb5af4b9be1325b61c7f80e71c7d50892ae22956 (patch) | |
tree | 236caabf92576f3a4d9708bc03768340782f09e7 /qtip/cli/utils.py | |
parent | a5145885c7a43622f803534ed97890ef9acb852d (diff) |
Implement 'show' command.
- Render the description via templates
JIRA: QTIP-205
Change-Id: I10523f85f80350e901a4a701bb65ca4833f8ff7c
Signed-off-by: Taseer Ahmed <taseer94@gmail.com>
Diffstat (limited to 'qtip/cli/utils.py')
-rw-r--r-- | qtip/cli/utils.py | 13 |
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 |