utils: replace Formatter with custom Template

The string.Formatter class does not support arbitrary formats of the
replacement markers and modifiers that are not limited to one character
would be nice. So a custom string.Template subclass is used now.

Sadly string.Template could not easily be monkey patched or extended
with inheritance because the interesting function is nested in other
ones and use a variable from the outer scope. Therefore a extra wrapper
class for compiled regular expressions is required (compiled regular
expressions could not monkey patched either, because it is implemented
in native c code).