OSDN Git Service

Change thread dat dir and idx dir.
[fukui-no-namari/fukui-no-namari.git] / src / Hage1 / misc.py
index 9bf1d7f..08cb313 100644 (file)
@@ -29,6 +29,24 @@ MON_DICT = {"Jan":1, "Feb":2, "Mar":3, "Apr":4, "May":5, "Jun":6, "Jul":7,
 def get_logs_dir_path():
     return os.path.join(config.get_config_dir_path(), "logs")
 
+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 os.path.join(get_board_dir_path(bbs, board), "dat")
+
+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:
+        raise ValueError, "parameter must not be empty"
+
+    return os.path.join(get_board_dir_path(bbs, board), "idx")
+
 def get_thread_dat_path(bbs, board, thread):
     """Returns thread dat file path
 
@@ -43,7 +61,7 @@ def get_thread_dat_path(bbs, board, thread):
     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
@@ -117,7 +135,7 @@ def get_thread_idx_path(bbs, board, thread):
     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
@@ -133,7 +151,7 @@ def get_board_cache_path(bbs, 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"""