cppy is a tool for programmatically generating embedded content within a file. It is similar in concept to the C/C++ preprocessor macro, except that the embedded code is expressed in python, allowing a far richer set of possibilities for content generation. The tool reads an input file and searches for the embedded python code. It extracts this code, runs it through a python interpreter, and replaces it with the output from the interpreter.
Input files are not limited to C/C++ source. The embedded python code blocks can be placed within any text file, such as xml/html, css, or javascript files.
The embedded code must be contained with specific markers within the file. Three types of markers are currently supported.
#py 'some python code'
//py 'some python code'
/*py
'some python code'
*/
<!--py 'some python code' -->
cppy is licensed under the MIT license.
The source code is available at http://github.com/hartcw/cppy.
cppy was created by Francis Hart for http://hartcw.com.