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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Yusei Tahara
slapos.recipe.template
Commits
964d0f7c
Commit
964d0f7c
authored
May 18, 2015
by
Saurabh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jinja2: fix display of source in traceback
parent
e9b7c1b2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
18 deletions
+23
-18
CHANGES.txt
CHANGES.txt
+6
-0
setup.py
setup.py
+1
-1
slapos/recipe/template/jinja2_template.py
slapos/recipe/template/jinja2_template.py
+16
-17
No files found.
CHANGES.txt
View file @
964d0f7c
2.7 (2015-05-18)
================
* jinja2: fix display of source in traceback when there is an error in the
root template (or in instance parameters).
2.6 (2014-11-26)
================
...
...
setup.py
View file @
964d0f7c
from
setuptools
import
setup
,
find_packages
import
os
version
=
'2.
6
'
version
=
'2.
7
'
name
=
'slapos.recipe.template'
long_description
=
open
(
"README.txt"
).
read
()
+
"
\
n
"
+
\
open
(
os
.
path
.
join
(
'slapos'
,
'recipe'
,
...
...
slapos/recipe/template/jinja2_template.py
View file @
964d0f7c
...
...
@@ -134,14 +134,13 @@ LOADER_TYPE_DICT = {
class
Recipe
(
object
):
mode
=
0777
# BBB: 0666 may have been a better default value
loader
=
None
umask
=
None
def
__init__
(
self
,
buildout
,
name
,
options
):
template
=
options
[
'template'
]
if
template
.
startswith
(
'inline:'
):
templat
e
=
template
[
7
:].
lstrip
(
'
\
r
\
n
'
)
self
.
get_template
=
lambda
:
template
sourc
e
=
template
[
7
:].
lstrip
(
'
\
r
\
n
'
)
template
=
'<inline>'
else
:
template
=
zc
.
buildout
.
download
.
Download
(
buildout
[
'buildout'
],
...
...
@@ -150,7 +149,7 @@ class Recipe(object):
template
,
md5sum
=
options
.
get
(
'md5sum'
),
)[
0
]
s
elf
.
get_template
=
lambda
:
open
(
template
).
read
()
s
ource
=
open
(
template
).
read
()
import_delimiter
=
options
.
get
(
'import-delimiter'
,
DEFAULT_IMPORT_DELIMITER
)
import_dict
=
{}
...
...
@@ -167,10 +166,12 @@ class Recipe(object):
import_delimiter
,
)
if
import_dict
:
self
.
loader
=
RelaxedPrefixLoader
(
import_dict
,
loader
=
RelaxedPrefixLoader
(
import_dict
,
delimiter
=
import_delimiter
)
else
:
loader
=
None
self
.
rendered
=
options
[
'rendered'
]
self
.
extension_list
=
[
x
for
x
in
(
y
.
strip
()
extension_list
=
[
x
for
x
in
(
y
.
strip
()
for
y
in
options
.
get
(
'extensions'
,
''
).
split
())
if
x
]
self
.
context
=
context
=
DEFAULT_CONTEXT
.
copy
()
if
_buildout_safe_dumps
is
not
None
:
...
...
@@ -191,6 +192,14 @@ class Recipe(object):
umask_value
=
options
.
get
(
'umask'
)
if
umask_value
:
self
.
umask
=
int
(
umask_value
,
8
)
env
=
Environment
(
extensions
=
extension_list
,
undefined
=
StrictUndefined
,
loader
=
loader
)
# For overriding from_string method of jinja2
self
.
template
=
env
.
template_class
.
from_code
(
env
,
env
.
compile
(
source
,
filename
=
template
),
env
.
make_globals
(
None
),
None
)
def
install
(
self
):
# Unlink any existing file, so umask is always applied.
...
...
@@ -208,17 +217,7 @@ class Recipe(object):
with
os
.
fdopen
(
os
.
open
(
self
.
rendered
,
os
.
O_CREAT
|
os
.
O_EXCL
|
os
.
O_WRONLY
,
self
.
mode
),
'w'
)
as
out
:
out
.
write
(
Environment
(
extensions
=
self
.
extension_list
,
undefined
=
StrictUndefined
,
loader
=
self
.
loader
,
).
from_string
(
self
.
get_template
(),
).
render
(
**
self
.
context
)
)
out
.
write
(
self
.
template
.
render
(
**
self
.
context
))
return
self
.
rendered
update
=
install
...
...
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