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
nexedi
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
Hide 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,29 +210,25 @@ class Recipe(object):
...
@@ -210,29 +210,25 @@ class Recipe(object):
if
self
.
once
and
os
.
path
.
exists
(
self
.
once
):
if
self
.
once
and
os
.
path
.
exists
(
self
.
once
):
return
return
template
=
self
.
template
template
=
self
.
template
env
=
self
.
env
if
template
.
startswith
(
'inline:'
):
if
template
.
startswith
(
'inline:'
):
source
=
template
[
7
:].
lstrip
(
'
\
r
\
n
'
)
source
=
template
[
7
:].
lstrip
(
'
\
r
\
n
'
)
template
=
'<inline>'
template
=
'<inline>'
compiled_source
=
env
.
compile
(
source
,
filename
=
template
)
else
:
else
:
template
=
zc
.
buildout
.
download
.
Download
(
try
:
self
.
buildout
[
'buildout'
],
compiled_source
=
compiled_source_cache
[
self
.
template
]
hash_name
=
True
,
except
KeyError
:
)(
template
=
zc
.
buildout
.
download
.
Download
(
template
,
self
.
buildout
[
'buildout'
],
md5sum
=
self
.
md5sum
,
hash_name
=
True
,
)[
0
]
)(
with
open
(
template
,
'rb'
)
as
f
:
template
,
source
=
f
.
read
().
decode
(
self
.
encoding
)
md5sum
=
self
.
md5sum
,
env
=
self
.
env
)[
0
]
with
open
(
template
,
'rb'
)
as
f
:
# get compiled source
source
=
f
.
read
().
decode
(
self
.
encoding
)
if
template
==
'<inline>'
:
compiled_source_cache
[
self
.
template
]
=
compiled_source
=
env
.
compile
(
source
,
filename
=
template
)
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
)
template
=
env
.
template_class
.
from_code
(
env
,
template
=
env
.
template_class
.
from_code
(
env
,
compiled_source
,
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