Skip to content

Commit

Permalink
Fix #5911: render_resource
Browse files Browse the repository at this point in the history
  • Loading branch information
git-user committed Jul 7, 2023
1 parent 6241198 commit 03c706d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions sirepo/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 03c706d

Please sign in to comment.