def __generate_file(self, template_filename, context, generated_filename, force=False):
        """
        Generate **one** (source code) file from a template.

        The file is **only** generated if needed, i.e. if ``force`` is set to ``True`` or if generated file is older
        than the template file. The generated file is written in the same directory as the template file.

        Args:
            template_filename (str): **Absolute** filename of a template file to translate.
            context (dict): Dictionary with ``(key, val)`` replacements.
            generated_filename (str): **Absolute** filename of the generated file filename.
            force (bool): If set to ``True``, file is generated no matter what.


        """
        # TODO: maybe avoid reading same template file again and again... i.e. parse it once and generate all needed files without reparsing the template.
        # test if file is non existing or needs to be regenerated
        if force or (not os.path.isfile(generated_filename) or os.stat(template_filename).st_mtime - os.stat(generated_filename).st_mtime > 1):
            self.log_info('   Parsing file %s' % template_filename)
            code_generated = self.__jinja2_environment.get_template(template_filename).render(context)

            with open(generated_filename, 'w') as f:
                self.log_info('   Generating file %s' % generated_filename)
                f.write(code_generated.encode('utf8'))