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
21 from bbs_type_exception import BbsTypeError
25 """Base of bbs type. Do not instantiate directly"""
31 def __init__(self, uri):
39 def _parse_uri(self, uri):
41 m = self._base_reg.match(self.uri)
43 self.host = m.group("host")
44 self.board = m.group("board")
46 m = self._cgi_reg.match(self.uri)
48 self.host = m.group("host")
49 self.board = m.group("board")
50 self.thread = m.group("thread")
53 "the uri %s does not represent %s" \
54 % (self.uri, self.bbs_type)
57 return not self.thread
62 def clone_with_thread(self, thread):
64 raise ValueError, "parameter must not be empty"
65 another = copy.copy(self)
66 another.thread = thread
67 another.uri = another.get_thread_uri()
70 def get_uri_base(self):
71 return "http://" + self.host + "/" + self.board + "/"
73 def get_subject_txt_uri(self):
74 return self.get_uri_base() + "subject.txt"
76 def get_dat_uri(self):
78 raise BbsTypeError, "not specified thread"
79 return self.get_uri_base() + "dat/" + self.thread + ".dat"
81 def get_thread_uri(self):
83 raise BbsTypeError, "not specified thread"
84 return "http://" + self.host + "/test/read.cgi/" + \
85 self.board + "/" + self.thread + "/"
87 def get_board_dir_path(self):
88 """Returns board dir path from logs dir downward, not full path"""
90 return self.bbs_type + "/" + self.host + "/" + self.board