def __generate_file(self, template_filename, context, generated_filename, force=False):
<EOL>if force or (not os.path.isfile(generated_filename) or os.stat(template_filename).st_mtime - os.stat(generated_filename).st_mtime > <NUM_LIT:1>):<EOL><INDENT>self.log_info('<STR_LIT>' % template_filename)<EOL>code_generated = self.__jinja2_environment.get_template(template_filename).render(context)<EOL>with open(generated_filename, '<STR_LIT:w>') as f:<EOL><INDENT>self.log_info('<STR_LIT>' % generated_filename)<EOL>f.write(code_generated.encode('<STR_LIT:utf8>'))<EOL><DEDENT><DEDENT>
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.