def _GenerateSection(
      self, template_filename, template_mappings, output_writer,
      output_filename, access_mode='wb'):
    """Generates a section from template filename.

    Args:
      template_filename: a string containing the name of the template file.
      template_mpppings: a dictionary containing the template mappings, where
                         the key maps to the name of a template variable.
      output_writer: an output writer object (instance of OutputWriter).
      output_filename: string containing the name of the output file.
      access_mode: optional string containing the output file access mode.
    """
    template_string = self._ReadTemplateFile(template_filename)
    try:
      output_data = template_string.substitute(template_mappings)
    except __HOLE__ as exception:
      logging.error(u'Unable to format template: {0:s}'.format(
          template_filename))
      return

    output_writer.WriteFile(
        output_filename, output_data, access_mode=access_mode)
dataset/ETHPy150Open libyal/libyal/scripts/source-generate.py/SourceFileGenerator._GenerateSection