def filetypes_info_to_rows_header(infos, attrnames=None, header=None, flag_wrap_description=False,
                                  description_width=40):
    """
    Converts filetype information to a (multiline_rows, header) tuple that can be more easily be tabulated

    **Attention** uses ReST syntax, using a "|br|" marker for line break. It requires the .rst source
                  file to contain the following bit:

        .. |br| raw:: html

           <br />

    Args:
        infos: list of FileTypeInfo
        attrnames: list of attribute names (keys of FILE_TYPE_INFO_ATTRS).
                   Defaults to all attributes
        header: list of strings containing headers. If not passed, uses default names
        flag_wrap_description: whether to wrap the description text
        description_width: width to wrap the description text (effective only if
                           flag_wrap_description is True)

    Returns:
        tuple: (rows, header): rows is a list of lists
    """

    if attrnames is None:
        attrnames = FILE_TYPE_INFO_ATTRS.keys()
    if header is None:
        header = [FILE_TYPE_INFO_ATTRS[key] for key in attrnames]

    if flag_wrap_description:
        wr = textwrap.TextWrapper(width=description_width, subsequent_indent="|br| ")

    data = []
    for i, info in enumerate(infos):
        row = []
        for j, attrname in enumerate(attrnames):
            if attrname != "description" or not flag_wrap_description:
                row.append(info[attrname])
            else:
                row.append(wr.wrap(info[attrname]))
        data.append(row)

    return data, header