コード例 #1
0
def icon(path):    
    ext = splitext(path)[1]
    if ext == ".pdf":
        return "fas fa-file-pdf"
    if ext in EXCEL_EXT:
        return "fas fa-file-excel"
    if ext in POWERPOINT_EXT:
        return "fas fa-file-powerpoint"
    if ext in WORD_EXT:
        return "fas fa-file-word"
    if ext in ARCHIVE_EXT:
        return "fas fa-file-archive"
    if ext in CODE_EXT:
        return "fas fa-file-code"
    
    if is_directory(path):
        return "fas fa-folder"
    if is_text(path):
        return "fas fa-file-alt"
    if is_audio(path):
        return "fas fa-file-audio"
    if is_video(path):
        return "fas fa-file-video"
    if is_image(path):
        return "fas fa-file-image"
        
    
    return "fas fa-file"
コード例 #2
0
def get_meta(path):
    """
    Returns metadata informations about the path
    Raises an IOError if path is not a file
    """
    if os.path.isdir(path):
        raise IOError('{0} is not a file'.format(rm_fb_root(path)))

    return {
        'text': filter.is_text(path),
        'code': filter.is_code(path) or filter.is_pl(path)
        or filter.is_pltp(path),
        'image': filter.is_image(path),
        'excel': filter.is_excel(path),
        'downloadUrl': to_download_url(rm_fb_root(path))
    }
コード例 #3
0
 def test_is_text(self):
     self.assertTrue(filter.is_text(RES_DIR+"text.txt"))
     self.assertFalse(filter.is_text(RES_DIR+"image.png"))