def update_recent_change_cache(config_agent): folder_pages_full_path = config_agent.get_full_path("paths", "pages_path") path = os.path.join(folder_pages_full_path, ".zw_recent_changes_cache") buf = page.get_page_file_list_by_req_path(folder_pages_full_path = folder_pages_full_path, req_path = "~recent", sort_by_modified_ts = True) with open(path, "w") as f: f.write(buf)
def code_repl(match_obj): code = match_obj.group('code') code = code.split("\n")[1] if code.startswith("ls("): p = 'ls\("(?P<path>.+?)",\s*maxdepth\s*=\s*(?P<maxdepth>\d+)\s*\)' m = re.match(p, code, re.UNICODE | re.MULTILINE) req_path = m.group("path") full_path = os.path.join(folder_pages_full_path, req_path) max_depth = int(m.group("maxdepth")) if os.path.exists(full_path): buf = page.get_page_file_list_by_req_path(req_path = req_path, max_depth = max_depth, folder_pages_full_path = folder_pages_full_path) buf = sequence_to_unorder_list(buf.split("\n"), **view_settings) else: buf = "" return buf buf_fixed = "{{{#!zw\n%s\n}}}" % code return buf_fixed
def update_all_pages_list_cache(folder_pages_full_path): buf = page.get_page_file_list_by_req_path(folder_pages_full_path = folder_pages_full_path, req_path = "~all") path = os.path.join(folder_pages_full_path, ".zw_all_pages_list_cache") with open(path, "w") as f: f.write(buf)