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
Romain Courteaud
slapos.recipe.template
Commits
0cfe728d
Commit
0cfe728d
authored
Sep 14, 2011
by
Antoine Catton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding slapos.recipe.template:fragements for more generic recipe.
parent
19f44d2b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
151 additions
and
2 deletions
+151
-2
CHANGES.txt
CHANGES.txt
+2
-0
README.txt
README.txt
+55
-2
setup.py
setup.py
+1
-0
slapos/recipe/template/__init__.py
slapos/recipe/template/__init__.py
+0
-0
slapos/recipe/template/fragments.py
slapos/recipe/template/fragments.py
+93
-0
No files found.
CHANGES.txt
View file @
0cfe728d
...
...
@@ -2,6 +2,8 @@
================
* No changes yet.
* Added fragment variant recipe. Which allow to use “extends” option
in the template [Antoine Catton]
1.1 (2011-05-30)
================
...
...
README.txt
View file @
0cfe728d
======================
slapos.recipe.template
======================
...
...
@@ -5,7 +6,10 @@ Fully networked template recipe, reusing collective.recipe.template with
ability to download template over the network
Usage
-----
=====
Default recipe
--------------
::
...
...
@@ -13,12 +17,61 @@ Usage
parts = template
[template]
recipe = slapos.
cookbook:
template
recipe = slapos.
recipe.
template
url = http://server/with/template
# optional md5sum
md5sum = 1234567890
output = ${buildout:directory}/result
Fragment variant recipe
-----------------------
* buildout.cfg
::
[buildout]
parts = template
[template]
recipe = slapos.recipe.template:fragments
url = http:://server/recipes/main.cfg
md5sum = 1234567890
output = ${buildout:directory}/output.cfg
value = foobar
* http://server/recipe/main.cfg
::
[buildout]
extends =
# buildout:extends lines should look like that :
# file (relative or absolute path), space, md5sum
../fragments/parent.cfg
* http://server/fragments/parent.cfg
::
[example]
recipe = example.recipe
option = ${:value}
output.cfg of this example should be :
::
[buildout]
[example]
recipe = example.recipe
option = foobar
Note
----
All parameters except url and md5sum will be passed to
collective.recipe.template, so please visit
http://pypi.python.org/pypi/collective.recipe.template for full information.
setup.py
View file @
0cfe728d
...
...
@@ -29,5 +29,6 @@ setup(name=name,
entry_points
=
{
'zc.buildout'
:
[
'default = slapos.recipe.template:Recipe'
,
'fragments = slapos.recipe.template.fragments:Recipe'
,
]},
)
slapos/recipe/template.py
→
slapos/recipe/template
/__init__
.py
View file @
0cfe728d
File moved
slapos/recipe/template/fragments.py
0 → 100644
View file @
0cfe728d
##############################################################################
#
# Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import
ConfigParser
import
re
import
urlparse
import
collective.recipe.template
import
zc.buildout
class
Recipe
(
collective
.
recipe
.
template
.
Recipe
):
def
__init__
(
self
,
buildout
,
name
,
options
):
self
.
_download
=
zc
.
buildout
.
download
.
Download
(
buildout
[
'buildout'
],
hash_name
=
True
)
url
=
'%s %s'
%
(
options
.
pop
(
'url'
).
strip
(),
options
.
get
(
'md5sum'
))
if
'input'
not
in
options
:
options
[
'input'
]
=
'%s.in'
%
options
[
'output'
]
with
open
(
options
[
'input'
],
'w'
):
pass
# Prepare the file for collective recipe
buildout
=
ConfigParser
.
RawConfigParser
()
buildout
.
add_section
(
'buildout'
)
buildout
.
set
(
'buildout'
,
'extends'
,
url
)
self
.
extend_buildout
(
buildout
)
with
open
(
options
[
'input'
],
'w'
)
as
file_
:
buildout
.
write
(
file_
)
# else collective recipe will take care to yell at the user :)
collective
.
recipe
.
template
.
Recipe
.
__init__
(
self
,
buildout
,
name
,
options
)
def
install
(
self
):
return
collective
.
recipe
.
template
.
Recipe
.
install
(
self
)
+
[
self
.
input
]
def
extend_buildout
(
self
,
buildout
,
parent_url
=
None
):
extendsline_re
=
re
.
compile
(
r'^.* [0-9a-fA-F]{32}$'
)
extends
=
[
tuple
(
line
.
strip
().
rsplit
(
' '
,
1
))
for
line
in
buildout
.
get
(
'buildout'
,
'extends'
).
splitlines
()
if
extendsline_re
.
match
(
line
.
strip
())]
buildout
.
remove_option
(
'buildout'
,
'extends'
)
for
url
,
md5sum
in
extends
:
if
parent_url
is
not
None
:
url
=
urlparse
.
urljoin
(
parent_url
,
url
)
path
,
is_temp
=
self
.
_download
(
url
,
md5sum
=
md5sum
)
config_parent
=
ConfigParser
.
ConfigParser
()
with
open
(
path
,
'r'
)
as
file_
:
config_parent
.
readfp
(
file_
)
if
config_parent
.
has_option
(
'buildout'
,
'extends'
):
self
.
extend_buildout
(
config_parent
,
url
)
for
section
in
config_parent
.
sections
():
if
buildout
.
has_section
(
section
):
for
option
in
config_parent
.
options
(
section
):
if
not
buildout
.
has_option
(
section
,
option
):
buildout
.
set
(
section
,
option
,
config_parent
.
get
(
section
,
option
))
else
:
buildout
.
add_section
(
section
)
# Dumb copy of section
for
option
in
config_parent
.
options
(
section
):
buildout
.
set
(
section
,
option
,
config_parent
.
get
(
section
,
option
))
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