Skip to content

Commit 333d9ec

Browse files
remote/config: simplify ResourceConfig template loading
ResourceConfig passes a template loader with the directory name of the resource (exporter) config to jinja2.Environment(). Instead of using the Environment's loader to load the actual config, the config file is opened and read from manually and its content is then passed to jinja2.Environment.from_string(). Change that by using the designated jinja2.Environment.get_template() method to load the config. Signed-off-by: Bastian Krause <[email protected]>
1 parent 9741924 commit 333d9ec

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

labgrid/remote/config.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ def __attrs_post_init__(self):
2121
line_comment_prefix="##",
2222
)
2323
try:
24-
with open(self.filename) as file:
25-
template = env.from_string(file.read())
26-
except FileNotFoundError:
24+
template = env.get_template(os.path.basename(self.filename))
25+
except jinja2.TemplateNotFound:
2726
raise NoConfigFoundError(f"{self.filename} could not be found")
2827
rendered = template.render(self.template_env)
2928
pprint(("rendered", rendered))

0 commit comments

Comments
 (0)