ZC buildout recipe to build template based file
Project description
What is iw.recipe.template ?
iw.recipe.template is a zc.buildout recipe to build template based file/scripts
It also provide some recipe to build Zope2, Zope3 and Squid vhosts config file for apache.
How to use iw.recipe.template ?
We need a buildout config file:
>>> server = start_server(test_dir) >>> write(sample_buildout, 'buildout.cfg', ... """ ... [buildout] ... parts = template.txt ... ... [template.txt] ... recipe = iw.recipe.template ... source = %s/template.txt_impl ... destination = %s/ ... """ % (sample_buildout, sample_buildout))
And a template:
>>> template = join(sample_buildout, 'template.txt_impl') >>> open(template, 'w').write('''My template is named "$name"''')
Then, the recipe should work:
>>> print system(buildout) Installing template.txt. template.txt: Generated file 'template.txt'.
Here is the result:
>>> print open(join(sample_buildout, 'template.txt')).read() My template is named "template.txt"
Now we can generate an executable:
>>> write(sample_buildout, 'buildout.cfg', ... """ ... [buildout] ... parts = script ... ... [script] ... recipe = iw.recipe.template:script ... source = %s/template.py_impl ... destination = %s/ ... """ % (sample_buildout, sample_buildout))
We need a small template with a python script:
>>> template = join(sample_buildout, 'template.py_impl') >>> open(template, 'w').write(''' ... import sys ... print 'this is the script named "$name"' ... ''')
Run buildout again:
>>> print system(buildout) Uninstalling template.txt. Installing script. script: Generated script 'script'.
Here is the result:
>>> print open(join(sample_buildout, 'script')).read() #!/.../bin/python <BLANKLINE> import sys print 'this is the script named "script"' <BLANKLINE> >>> print system(join(sample_buildout, 'script')) this is the script named "script"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
iw.recipe.template-0.2-py2.4.egg
(12.8 kB
view details)
File details
Details for the file iw.recipe.template-0.2.tar.gz
.
File metadata
- Download URL: iw.recipe.template-0.2.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac8407061d4677234ee7a90de58d2e66b301ad316f52e27c61f74a387549234c |
|
MD5 | b0a655c210ec4c28a7dbdc34bab3cbe9 |
|
BLAKE2b-256 | 3a1c96b9d4f2808b461fc37d0cda42e1240a248ba8a6f04bef0d670bc7f3b366 |
File details
Details for the file iw.recipe.template-0.2-py2.4.egg
.
File metadata
- Download URL: iw.recipe.template-0.2-py2.4.egg
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2df8652f4055e35fb7084701e8322ac0c0f62e797f439730ec3245fc45db4182 |
|
MD5 | 36ec09d717eabc943da9a2eb6652c21a |
|
BLAKE2b-256 | 9b5b219315dc7952bf9cb2f097b99399805b38d45c8495d4e160ebb738cd73e5 |