def _write_data(writer, data, section):
    """
    Writes datachars to writer and deals with < >
    @param      writer      stream or file
    @param      data        string to write
    @param      section     depending of this name,
                            some special characters are processed or not (pre or !pre)
    """
    if data:
        if section == 'pre':
            data = data.replace('&', '&amp;').replace('<', '&lt;').replace('>',
                '&gt;')
        elif section == 'script':
            pass
        else:
            if section is None:
                raise ValueError('section name is empty')
            data = data.replace('&', '&amp;').replace('<', '&lt;').replace('"',
                '&quot;').replace('>', '&gt;')
        writer.write(data)
