zc.buildout recipe for creating files from file templates

## Basic Usage

With the as.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 variable substitution and write the result to the corresponding output files.

The recipe has several features, but it always takes template files with a .in suffix, processes the template, and writes out the file to the desired location with the same file mode, and the same name but without the .in suffix.

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 as.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 = message ... ... [message] ... recipe = as.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 message.

>>> cat(sample_buildout, 'helloworld.txt')
Hello Philipp!


### 2.0.3 (2009-07-02)

Fixes

• Use realpath helper function from zc.buildout on the buildout directory too, such that it goes through the same normalization as the path being compared and stands a chance of working on Windows, due to possible drive letter case differences.

### 2.0.2 (2009-05-04)

Fixes

• Turns out sorting paths was a bad idea. They are already in a deterministic order, AFAICT, because of the order or processing dependencies. Sorting them makes them less deterministic in practice, across machines.

### 2.0.1 (2009-04-30)

Fixes

• Correct sdist generation to include all necessary files.

• Doc formatting fixes.

• Correct “Destinations already exist” message to list destinations without .in suffix.

### 2.0 (2009-04-30)

Features

• Store your template files in a separate directory structure, using the source-directory option.

• Specify multiple files automatically with globs.

• Templates can reference other buildout sections using the usual syntax, e.g. \${buildout:parts}

• Share options with other sections using the typical extends option.

• Create destination directories automatically.

• Define option values for templates dynamically in Python with the interpreted-options option.

• Get paths for eggs by specifying eggs and extra-paths, just like zc.recipe.egg script recipe. These are available in template options in colon-delimited, space-delimited, and quoted variants. You can also build your own using the interpreted-options feature.

• Templates are not processed if there are no changes to them or the buildout.

Initial release.

## Project details

Uploaded source
Uploaded 2 7