def mimetype_to_icon(mtype):
    """Converts a file mime type into an icon
	to be displayed next to the file name.
	"""
    ficon = 'fa fa-fw fa-file-o'
    if mtype.startswith('image'):
        ficon = 'fa fa-fw fa-file-image-o'
    elif mtype.startswith('audio'):
        ficon = 'fa fa-fw fa-file-audio-o'
    elif mtype.startswith('video'):
        ficon = 'fa fa-fw fa-file-video-o'
    elif mtype.startswith('message'):
        ficon = 'fa fa-fw fa-envelope'
    elif mtype.startswith('application/vnd.visio'):
        ficon = 'fa fa-fw fa-sitemap'
    elif mtype.startswith('application/octet-stream'):
        ficon = 'fa fa-fw fa-cogs'
    elif mtype.startswith('application/x-gzip'):
        ficon = 'fa fa-fw fa-file-archive-o'
    elif mtype.startswith('application/x-gtar'):
        ficon = 'fa fa-fw fa-file-archive-o'
    elif mtype.startswith('application/x-tar'):
        ficon = 'fa fa-fw fa-file-archive-o'
    elif mtype.startswith('application/zip'):
        ficon = 'fa fa-fw fa-file-archive-o'
    elif mtype.startswith('application/vnd.ms-cab-compressed'):
        ficon = 'fa fa-fw fa-file-archive-o'
    elif mtype.startswith('application/x-rpm'):
        ficon = 'fa fa-fw fa-file-archive-o'
    elif mtype.startswith(
        'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'):
        ficon = 'fa fa-fw fa-file-excel-o'
    elif mtype.startswith('application/vnd.ms-excel'):
        ficon = 'fa fa-fw fa-file-excel-o'
    elif mtype.startswith('application/vnd.oasis.opendocument.spreadsheet'):
        ficon = 'fa fa-fw fa-table'
    elif mtype.startswith('application/msword'):
        ficon = 'fa fa-fw fa-file-word-o'
    elif mtype.startswith(
        'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
        ):
        ficon = 'fa fa-fw fa-file-word-o'
    elif mtype.startswith('application/vnd.oasis.opendocument.text'):
        ficon = 'fa fa-fw fa-file-text-o'
    elif mtype.startswith('application/vnd.ms-powerpoint'):
        ficon = 'fa fa-fw fa-file-powerpoint-o'
    elif mtype.startswith(
        'application/vnd.openxmlformats-officedocument.presentationml.presentation'
        ):
        ficon = 'fa fa-fw fa-file-powerpoint-o'
    elif mtype.startswith('application/vnd.oasis.opendocument.presentation'):
        ficon = 'fa fa-fw fa-slideshare'
    elif mtype.startswith('application/pdf'):
        ficon = 'fa fa-fw fa-file-pdf-o'
    elif mtype.startswith('text/html'):
        ficon = 'fa fa-fw fa-file-code-o'
    elif mtype.startswith('application/xhtml+xml'):
        ficon = 'fa fa-fw fa-file-code-o'
    elif mtype.startswith('text/css'):
        ficon = 'fa fa-fw fa-file-code-o'
    elif mtype.startswith('text/xml') or mtype.startswith('application/xml'):
        ficon = 'fa fa-fw fa-code-o'
    elif mtype.startswith('application/x-perl'):
        ficon = 'fa fa-fw fa-file-code-o'
    elif mtype.startswith('application/x-python'):
        ficon = 'fa fa-fw fa-file-code-o'
    elif mtype.startswith('text/x-python'):
        ficon = 'fa fa-fw fa-file-code-o'
    elif mtype.startswith('application/x-perl'):
        ficon = 'fa fa-fw fa-file-code-o'
    elif mtype.startswith('application/x-sh'):
        ficon = 'fa fa-fw fa-terminal'
    elif mtype.startswith('text/plain'):
        ficon = 'fa fa-fw fa-file-text-o'
    elif mtype.startswith('application'):
        ficon = 'fa fa-fw fa-cog'
    return ficon
