summaryrefslogtreecommitdiffstats
path: root/robotframework-onap
diff options
context:
space:
mode:
authorDR695H <dr695h@att.com>2019-05-21 14:02:32 -0400
committerDR695H <dr695h@att.com>2019-05-21 14:03:16 -0400
commit26ef55453fd4950cd5841c098b5b1473b09d7be5 (patch)
treea707483c716cfdb66f0987c00f27f62e5061824e /robotframework-onap
parentb911603f288d237b433cad9d488c2fa2d6985df7 (diff)
redo tempalteengine to not need param in init
init causes robot to do some weird things if it has a parameter in it so remvoing it Change-Id: If63eb640c8ce1f38a206d9dbee84143b798707d4 Issue-ID: TEST-155 Signed-off-by: DR695H <dr695h@att.com>
Diffstat (limited to 'robotframework-onap')
-rw-r--r--robotframework-onap/eteutils/TemplatingEngine.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/robotframework-onap/eteutils/TemplatingEngine.py b/robotframework-onap/eteutils/TemplatingEngine.py
index 5e701a7..b47cf8e 100644
--- a/robotframework-onap/eteutils/TemplatingEngine.py
+++ b/robotframework-onap/eteutils/TemplatingEngine.py
@@ -14,20 +14,23 @@
from jinja2 import Environment, FileSystemLoader, select_autoescape
+from robot import utils
-class TemplatingEngine:
+class TemplatingEngine(object):
"""TemplateImporter is common resource for templating with strings."""
- jinja_env = None
+ def __init__(self):
+ self._cache = utils.ConnectionCache('No Jinja Environments created')
- def __init__(self, templates_folder):
- self.jinja_env = Environment(
+ def create_environment(self, alias, templates_folder):
+ jinja_env = Environment(
loader=FileSystemLoader(templates_folder),
autoescape=select_autoescape(['html', 'xml'])
)
+ self._cache.register(jinja_env, alias=alias)
- def apply_template(self, template_location, values):
+ def apply_template(self, alias, template_location, values):
"""returns a string that is the jinja template in template_location filled in via the dictionary in values """
- template = self.jinja_env.get_template(template_location)
+ template = self._cache.switch(alias).get_template(template_location)
return template.render(values)