1 # Copyright (C) 2006 by Aiwota Programmer
2 # aiwotaprog@tetteke.tk
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 def get_logs_dir_path():
24 return os.path.join(config.get_config_dir_path(), "logs")
26 def get_board_base_url(bbs, board):
28 None: this function uses brdlist.get function, so brdlist.read function
29 should have been called before this function is called
31 # if parameter is empty, raise ValueError
32 if not bbs or not board:
33 raise ValueError, "parameter must not be empty"
35 return "http://" + brdlist.get(bbs, board, "host") + "/" + board + "/"
37 def get_thread_dat_path(bbs, board, thread):
38 """Returns thread dat file path
47 # if parameter is empty, raise ValueError
48 if not bbs or not board or not thread:
49 raise ValueError, "parameter must not be empty"
51 return os.path.join(get_board_dir_path(bbs, board), thread + ".dat")
53 def get_board_subjecttxt_url(bbs, board):
54 """Returns subject.txt file url
61 # if parameter is empty, raise ValueError
62 if not bbs or not board:
63 raise ValueError, "parameter must not be empty"
65 return get_board_base_url(bbs, board) + "subject.txt"
67 def get_board_subjecttxt_path(bbs, board):
68 """Returns subject.txt file path
75 # if parameter is empty, raise ValueError
76 if not bbs or not board:
77 raise ValueError, "parameter must not be empty"
79 return os.path.join(get_logs_dir_path(), bbs, board, "subject.txt")
81 def get_board_dir_path(bbs, board):
82 """Returns board dir path
89 # if parameter is empty, raise ValueError
90 if not bbs or not board:
91 raise ValueError, "parameter must not be empty"
93 return os.path.join(get_logs_dir_path(), bbs, board)
95 def get_thread_idx_path(bbs, board, thread):
96 """Returns idx file path of thread
104 Note: if parameter is empty, raise ValueError
107 # if parameter is empty, raise ValueError
108 if not bbs or not board or not thread:
109 raise ValueError, "parameter must not be empty"
111 return os.path.join(get_logs_dir_path(), bbs, board, thread + ".idx")
113 def get_board_cache_path(bbs, board):
114 """ Returns .cache file path of board
120 Note: if parameter is empty, raise ValueError
123 # if parameter is empty, raise ValueError
124 if not bbs or not board:
125 raise ValueError, "parameter must not be empty"
127 return os.path.join(get_logs_dir_path(), bbs, board, ".cache")