import os
import os.path
from fileinput import FileInput
-from misc import get_thread_idx_path
+import misc
metadata_namelist = ["title", "lineCount", "lastModified", "etag"]
-def load_idx(bbs, board, thread):
+def load_idx(bbs_type):
"""Loads index file of thread
bbs: bbs id
return dictionary which key is in metadata_namelist if idx file exist,
otherwise return empty dic
"""
- idxfile_path = get_thread_idx_path(bbs, board, thread)
+ idxfile_path = misc.get_thread_idx_path(bbs_type)
if not os.path.exists(idxfile_path):
return {"title":None,"lineCount":0,"lastModified":None,"etag":None}
datadic[name] = ""
return datadic
-def save_idx(bbs, board, thread, datadic):
+def save_idx(bbs_type, datadic):
"""Saves thread metadatas to a index file
bbs: bbs id
"""
# create a directory where idx file should belong if does not exist
- idxfile_path = get_thread_idx_path(bbs, board, thread)
+ idxfile_path = misc.get_thread_idx_path(bbs_type)
basedir = os.path.dirname(idxfile_path)
if not os.path.isdir(basedir):
os.makedirs(basedir)