About
Produce a set of files and directories based on a "template" set of files and directories and a some data (usually a dict of "vars"). Replace variables in file and directory names as well as file contents. Comes with a nice (I think) command line interface but is also a utility for building frameworks and such. Supports pluggable "filters" so you could use Kid or Cheetah or probably any other templating language that you need.
By default the Builder class catches +foo+
in a directory or file name in the template and replaces it with
the value of builder.data['foo'] (if found).
For each file name, a list of filters is checked to see if one
applies. The first matching filter is used to transform the
filename (usually just to remove an extra extension) and to filter
the text based on the Builder instance's data.
The included filter uses string.Template's
safe_substitute and catches
anything ending with the .tpl extension, which it removes.
Downloads and Updates
Download the latest release from skel's Cheese Shop Page. (Blessed are the cheesemakers!)
Browse skel's public subversion repository.
Read and subscribe to skel updates and info.
Command Line Interface
usage: skelcmd template_dir destination_dir [options]
options:
--version show program's version number and exit
-h, --help show this help message and exit
-i IGNORE, --ignore=IGNORE
comma separated list of patterns to ignore
-o, --overwrite overwrite existing files
-k, --keep keep existing files
-d DATA, --data=DATA vars for replacement like foo=bar,spam=eggs
-f FILE, --file=FILE file containing vars whitespace separated like foo=bar
spam=eggs
-p, --prompt prompt for all variables
-r REGEX, --regex=REGEX
regex for identifying variables in paths (must have
named group "key")
API Usage
from skel import Builder, prompt_for_dct, StringTemplateFilter
data = dict(foo='', bar='', baz='')
data = prompt_for_dct(data)
builder = Builder(data, ignore=['.svn', 'CVS'],
filters=[StringTemplateFilter()], overwrite='PROMPT')
numdirs, numfiles = builder.build('mytemplate', 'myproject')
print numdir, "directories created"
print numfiles, "files written"
Questions, comments, suggestions, bugs... : luke.arno@gmail.com