Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vyos.template: T3664: use a module-level global variable for the default template directory (backport #3415) #3416

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions python/vyos/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@
from vyos.utils.permission import chmod
from vyos.utils.permission import chown

# We use a mutable global variable for the default template directory
# to make it possible to call scripts from this repository
# outside of live VyOS systems.
# If something (like the image build scripts)
# want to call a script, they can modify the default location
# to the repository path.
DEFAULT_TEMPLATE_DIR = directories["templates"]

# Holds template filters registered via register_filter()
_FILTERS = {}
_TESTS = {}
Expand All @@ -33,7 +41,11 @@
@functools.lru_cache(maxsize=2)
def _get_environment(location=None):
if location is None:
<<<<<<< HEAD
loc_loader=FileSystemLoader(directories["templates"])
=======
loc_loader=FileSystemLoader(DEFAULT_TEMPLATE_DIR)
>>>>>>> 9aa8c3cd9 (vyos.template: T3664: use a module-level global variable for the default template directory)
else:
loc_loader=FileSystemLoader(location)
env = Environment(
Expand Down
Loading