zc.buildout recipe for creating files from file templates
Project description
With the z3c.recipe.filetemplate buildout recipe you can automate the generation of text files from templates. Upon execution, the recipe will read a number of template files, perform a simple variable substitution and write the result to the corresponding output files.
For example, consider this simple template for a text file:
>>> write(sample_buildout, 'helloworld.txt.in', ... """ ... Hello ${world}! ... """)
Now let’s create a buildout configuration so that we can substitute the values in this file. All we have to do is define a part that uses the z3c.recipe.filetemplate recipe. With the files parameter we specify one or more files that need substitution (separated by whitespace). Then we can add arbitrary parameters to the section. Those will be used to fill the variables in the template:
>>> write(sample_buildout, 'buildout.cfg', ... """ ... [buildout] ... parts = file ... ... [file] ... recipe = z3c.recipe.filetemplate ... files = helloworld.txt ... world = Philipp ... """)
After executing buildout, we can see that $world has indeed been replaced by Philipp:
>>> print system(buildout) Installing file.>>> cat(sample_buildout, 'helloworld.txt') Hello Philipp!
Changes
1.0 (2007-09-30)
Initial release.
Project details
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
File details
Details for the file z3c.recipe.filetemplate-1.0.tar.gz
.
File metadata
- Download URL: z3c.recipe.filetemplate-1.0.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39d847f38b49b9c546738b1646d9ede1041508ab11a9cb1b1087feaa583d5613 |
|
MD5 | b304eaeed61e8154bae4ac1f6291637f |
|
BLAKE2b-256 | d1ca13826b65b5eaa0b2e37a67b702e01054b1cd1ee4bcc42e998c325811528f |
File details
Details for the file z3c.recipe.filetemplate-1.0-py2.4.egg
.
File metadata
- Download URL: z3c.recipe.filetemplate-1.0-py2.4.egg
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89112b61bdbd61bd81dfb6693a40813f8ecf0bd5f20770bac360447e23777188 |
|
MD5 | f260ed278824e977c8064388b668d187 |
|
BLAKE2b-256 | 241757704a6dd2e0481c39d4e4a9151b28c307d7c8a4b5fd6e7aedbc114606bd |