Skip to content

The template system

sangfroid.template #

Unless you are developing sangfroid itself, you don't need to worry about this module.

The template system helps to keep sangfroid's classes synchronised with the XML that synfig actually writes out. It is rather hacky and incomplete.

There are two places we can find out about the XML. One of them is by inspecting actual XML; the other is by reading Synfig's own sources. The XML system actually works somewhat; the sources system is too unstable for ordinary use.

There is a file in the tests directory called pick-and-mix.sif (named after the department in British supermarkets where you can choose from many different kinds of sweets). The template system scans this file and updates sangfroid's Python source as appropriate.

You can run the system with:

PYTHONPATH=. python -m sangfroid.template

Make sure you're in a clean source tree before you start.

Each .py file in all subdirectories of sangfroid is considered for updating. The markers ### {{{ and ### }}}, on their own lines, delimit the areas that the templating system is allowed to touch. The ### {{{ marker may be indented with spaces; the text between the markers will be indented to the same level.

If a Python keyword follows ### {{{, it is the name of the layer type to describe in the following block. If there is no keyword, which is the usual case, then the name is taken from the most recent class definition which had no indentation.

All the data we find must be written out somewhere; it is an error if there are no template blocks for a layer type we know about.