Create a file from a template if it doesn't already exist.

def mk_tmpl(self, path, tmpl, ctx, mode=None):
        """Create a file from a template if it doesn't already exist.
        """

        path = os.path.abspath(path)

        if os.path.isfile(path):
            logger.warning("File %s already exists, not creating it.", tmpl)

        with open(path, 'w') as fd:
            fd.write(
                tmpl.format(**ctx)
            )
            if mode:
                os.chmod(path, mode)