First version after much tinkering.
Working, requires Linux (uses bash scripting) and Python (and HamlPy).