Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.recipe.template
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
slapos.recipe.template
Commits
9db182e8
Commit
9db182e8
authored
Jan 18, 2018
by
Yusei Tahara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jinja2_template.py: Improve the previous change. Query cache before download/read template.
parent
f8b08cbc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
19 deletions
+15
-19
slapos/recipe/template/jinja2_template.py
slapos/recipe/template/jinja2_template.py
+15
-19
No files found.
slapos/recipe/template/jinja2_template.py
View file @
9db182e8
...
...
@@ -210,10 +210,15 @@ class Recipe(object):
if
self
.
once
and
os
.
path
.
exists
(
self
.
once
):
return
template
=
self
.
template
env
=
self
.
env
if
template
.
startswith
(
'inline:'
):
source
=
template
[
7
:].
lstrip
(
'
\
r
\
n
'
)
template
=
'<inline>'
compiled_source
=
env
.
compile
(
source
,
filename
=
template
)
else
:
try
:
compiled_source
=
compiled_source_cache
[
self
.
template
]
except
KeyError
:
template
=
zc
.
buildout
.
download
.
Download
(
self
.
buildout
[
'buildout'
],
hash_name
=
True
,
...
...
@@ -223,16 +228,7 @@ class Recipe(object):
)[
0
]
with
open
(
template
,
'rb'
)
as
f
:
source
=
f
.
read
().
decode
(
self
.
encoding
)
env
=
self
.
env
# get compiled source
if
template
==
'<inline>'
:
compiled_source
=
env
.
compile
(
source
,
filename
=
template
)
else
:
try
:
compiled_source
=
compiled_source_cache
[
template
]
except
KeyError
:
compiled_source_cache
[
template
]
=
compiled_source
=
env
.
compile
(
source
,
filename
=
template
)
compiled_source_cache
[
self
.
template
]
=
compiled_source
=
env
.
compile
(
source
,
filename
=
template
)
template
=
env
.
template_class
.
from_code
(
env
,
compiled_source
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment