From 03c706d630764523640a98d2386e8246308651f8 Mon Sep 17 00:00:00 2001 From: git-user Date: Fri, 7 Jul 2023 19:35:37 +0000 Subject: [PATCH] Fix #5911: render_resource --- sirepo/resource.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sirepo/resource.py b/sirepo/resource.py index cbae686ce3..3fc8c05713 100644 --- a/sirepo/resource.py +++ b/sirepo/resource.py @@ -44,6 +44,26 @@ def glob_paths(*paths): ) +def render_resource(filename, resource_dir, run_dir, jinja_params): + """Render .jinja filename from resource_dir into run_dir + Args: + filename (str): .jinja filename + resource_dir (str): dir that .jinja template lives in + run_dir (py.path): target directory for rendered file + jinja_params (PKDict): parameters to jinja file + Returns: + py.path: path to rendered file + """ + from pykern import pkjinja + res = run_dir.join(filename) + pykern.pkjinja.render_file( + file_path(resource_dir + filename + pkjinja.RESOURCE_SUFFIX), + jinja_params, + output=res, + ) + return res + + def root_modules(): """Get all root modules in package_path