def POST(self): path = xutils.get_argument("path") if not path: path = xconfig.DATA_DIR path = os.path.abspath(path) find_key = xutils.get_argument("find_key", "") find_type = xutils.get_argument("type") mode = xutils.get_argument("mode") if find_key == "" or find_key is None: find_key = xutils.get_argument("key", "") find_key = "*" + find_key + "*" path_name = os.path.join(path, find_key) if find_key == "**": plist = [] elif path == os.path.abspath(xconfig.DATA_DIR) and xconfig.USE_CACHE_SEARCH: # search in cache plist = find_in_cache(find_key) else: plist = xutils.search_path(path, find_key) filelist = FS.process_file_list(plist, path) # TODO max result size tpl = "fs/page/fs.html" if mode == "grid": tpl = "fs/fs_grid.html" return xtemplate.render(tpl, path = path, token = xauth.get_current_user().token, filelist = filelist)
def on_search_books(ctx): if not xauth.is_admin(): return if not ctx.category == "book": return name = ctx.input_text # 图书搜索结果 bookspath = os.path.join(xconfig.DATA_DIR, "books") pathlist = xutils.search_path(bookspath, "*" + name + "*") if len(pathlist) > 0: url = "/fs_find?path=%s&find_key=%s"%(bookspath,name) ctx.tools.append(SearchResult("图书搜索结果(%s) - %s" % (len(pathlist), name), url))
def POST(self): path = xutils.get_argument("path") find_key = xutils.get_argument("find_key", "") find_type = xutils.get_argument("type") find_key = "*" + find_key + "*" path_name = os.path.join(path, find_key) if find_key == "": plist = [] else: plist = xutils.search_path(path, find_key) return xtemplate.render( "fs/fs.html", token=xauth.get_current_user().token, fspathlist=xutils.splitpath(path), filelist=[xutils.FileItem(p, path) for p in plist])
def POST(self): path = xutils.get_argument("path") find_key = xutils.get_argument("find_key", "") find_type = xutils.get_argument("type") if find_key == "" or find_key is None: find_key = xutils.get_argument("key", "") find_key = "*" + find_key + "*" path_name = os.path.join(path, find_key) if find_key == "**": plist = [] elif os.path.abspath(path) == os.path.abspath(xconfig.DATA_DIR) and xconfig.USE_CACHE_SEARCH: # search in cache plist = find_in_cache(find_key) else: plist = xutils.search_path(path, find_key) # TODO max result size return xtemplate.render("fs/fs.html", token = xauth.get_current_user().token, filelist = [xutils.FileItem(p, path) for p in plist])
def GET(self): key = xutils.get_argument("key") user_name = xauth.current_name() user_dir = os.path.join(xconfig.UPLOAD_DIR, user_name) find_key = "*" + key + "*" if find_key == "**": plist = [] else: plist = sorted(xutils.search_path(user_dir, find_key, "file")) return xtemplate.render("fs/fs_upload.html", show_aside=False, html_title=T("文件"), page="search", pathlist=plist, path=user_dir, dirname=user_dir, get_webpath=get_webpath, upload_link_by_month=upload_link_by_month, get_display_name=get_display_name)
def test_search_path(self): print(os.getcwd()) result = xutils.search_path("./", "*test*") self.assertTrue(len(result) > 0)