'Takes a filename and returns a category based on the file type.
Categories: word, excel, powerpoint, flash, pdf, image, video, audio, archive, other.'

@staticmethod
def doc_filetype(filename):

    parts = os.path.splitext(filename)
    if (len(parts) < 2):
        return 'other'
    else:
        ext = parts[1][1:].lower()
        if (ext in ('png', 'jpg', 'jpeg', 'gif')):
            return 'image'
        elif (ext in ('avi', 'mp4', 'm4v', 'ogv', 'wmv', 'mpg', 'mpeg')):
            return 'video'
        elif (ext in ('mp3', 'm4a', 'wav', 'ogg', 'aiff')):
            return 'audio'
        elif (ext in ('zip', '7z', 'tar', 'gz', 'tgz', 'bz2', 'rar')):
            return 'archive'
        elif (ext in ('doc', 'docx', 'dot', 'dotx', 'rtf')):
            return 'word'
        elif (ext in ('xls', 'xlsx', 'xlt', 'xltx', 'csv')):
            return 'excel'
        elif (ext in ('ppt', 'pptx')):
            return 'powerpoint'
        elif (ext in ('flv', 'swf')):
            return 'flash'
        elif (ext == 'pdf'):
            return 'pdf'
        else:
            return 'other'
