Skip to main content

A code template processor

Project description

The B Preprocessor
A code template processor

What is this?
This is a code templating pre-processor. In my work I often have to
write code which runs on multiple data files. The code has to be the
same, but the files differ in subtle ways: the number of files, the
format of the files, etc. Instead of writing one piece of code, then
tweaking it to work for each case, I write a B template, and put all
of the file-specific-subtleties into meta-data text files, and the B
pre-processor handles all of the case specific tweaking.

Why would I want this?
Readability
Everything is text files and python scripts. The output of the
preprocessor looks like normal code that was written from scratch.
I send code generated by the pre-processor to my boss all the time.
It makes him happy because it looks like code he writes; It makes
me happy because I don't have to be inefficient and write code his
way.
Flexibility
The preprocessor uses simple ideas: replacement, iteration, files
are treated as strings, the template boilerplate is handled with
the same rules as everything else. You can do some crazy things
with a little creativity.

Why didn't you just learn to use one of the other template scripting
languages?
Frankly, I wrote the first version of this over the course of two
hours. I needed something which worked, and I needed it fast. It would
have taken me longer to learn something new, than to make something
new.
Why B?
B comes before C! Most of my work coding is in C/C++. Now I can say
things like, "I wrote you A B C... ++ template for that." Actually, no,
thats a really limp joke.

when install with setuptools (or variant), an executable 'B' is added
to the user's path.

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

B_pp-1.1.tar.gz (8.6 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page