import time
import config
-import brdlist
REG_EXPR_HTTPDATE = re.compile("((?:Mon)|(?:Tue)|(?:Wed)|(?:Thu)|(?:Fri)|(?:Sat)|(?:Sun)), (\d{2}) ((?:Jan)|(?:Feb)|(?:Mar)|(?:Apr)|(?:May)|(?:Jun)|(?:Jul)|(?:Aug)|(?:Sep)|(?:Oct)|(?:Nov)|(?:Dec)) (\d{4}) (\d{2}):(\d{2}):(\d{2}) GMT")
WDAY_DICT = {"Mon":0, "Tue":1, "Wed":2, "Thu":3, "Fri":4, "Sat":5, "Sun":6}
def get_logs_dir_path():
return os.path.join(config.get_config_dir_path(), "logs")
-def get_board_base_url(bbs, board):
- """
- Note: this function uses brdlist.get function, so brdlist.init function
- should have been called before this function is called
- """
+def get_thread_dat_dir_path(bbs, board):
+ """Returns dir path for saving thread dat file"""
+
# if parameter is empty, raise ValueError
if not bbs or not board:
raise ValueError, "parameter must not be empty"
- return "http://" + brdlist.get(bbs, board, "host") + "/" + board + "/"
+ return os.path.join(get_board_dir_path(bbs, board), "dat")
-def get_thread_dat_url(bbs, board, thread):
- """Returns thread dat url"""
+def get_thread_idx_dir_path(bbs, board):
+ """Returns dir path for saving thread index file"""
# if parameter is empty, raise ValueError
- if not bbs or not board or not thread:
+ if not bbs or not board:
raise ValueError, "parameter must not be empty"
- return get_board_base_url(bbs, board) + "dat/" + thread + ".dat"
+ return os.path.join(get_board_dir_path(bbs, board), "idx")
def get_thread_dat_path(bbs, board, thread):
"""Returns thread dat file path
if not bbs or not board or not thread:
raise ValueError, "parameter must not be empty"
- return os.path.join(get_board_dir_path(bbs, board), thread + ".dat")
+ return os.path.join(get_thread_dat_dir_path(bbs, board), thread + ".dat")
def get_board_subjecttxt_url(bbs, board):
"""Returns subject.txt file url
if not bbs or not board or not thread:
raise ValueError, "parameter must not be empty"
- return os.path.join(get_logs_dir_path(), bbs, board, thread + ".idx")
+ return os.path.join(get_thread_idx_dir_path(bbs, board), thread + ".idx")
def get_board_cache_path(bbs, board):
""" Returns .cache file path of board
if not bbs or not board:
raise ValueError, "parameter must not be empty"
- return os.path.join(get_logs_dir_path(), bbs, board, ".cache")
+ return os.path.join(get_thread_idx_dir_path(bbs, board), ".cache")
def httpdate_to_secs(httpdate):
"""Returns the seconds since the epoch"""