TWINSの表に教室情報を追加したHTMLを返す。

def get_timetable_html (self, module):
        """ TWINSの表に教室情報を追加したHTMLを返す。"""
        if not module.startswith("春") and \
           not module.startswith("秋"):
            raise RequestError()
        module_code, gakkiKbnCode = {
                                      "春A": (1, "A"),
                                      "春B": (2, "A"),
                                      "春C": (3, "A"),
                                      "秋A": (4, "B"),
                                      "秋B": (5, "B"),
                                      "秋C": (6, "B")
                                    }.get(module)

        self.req("RSW0001000-flow")
        r = self.get({
                       "_eventId":   "search",
                       "moduleCode": module_code,
                       "gakkiKbnCode": gakkiKbnCode
                    })
        html = r.text[r.text.find("<!-- ===== 全体テーブル(開始) ===== -->"):
                      r.text.find("<!-- ===== 全体テーブル(終了) ===== -->")]

        # 要らないところを削る
        for x in ["集中講義を登録", "未登録",
                  "春A", "春B", "春C", "秋A", "秋B", "秋C", "夏休", "春休"]:
            html = html.replace(x, "")

        # 教室情報を追加する
        for c in self.get_registered_courses():
            if c["room"] != "":
                room = "(<span class='room'>%s</span>)" % c["room"]
            else:
                room = ""
            html = html.replace(c["id"], c["id"] + "</a><br>" + room)

        # 色を変える
        for from_, to in (("#dddddd", "#deded9"), ("#ffcc99", "#c4efff"),
                          ("#00bfff", "#fefefe")):
            html = html.replace(from_, to)
        return """
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>時間割 (%(module)s)</title>
<style>
body { font-family: sans-serif; background: #fff; color: #343434; }
a{ color: #3f3f3f; text-decoration: none; }
.rishu-etc-head, .rishu-koma-head { background: #6a8cc7; }
</style>
</head><body>
<h2>%(module)s 時間割</h2>
%(html)s
</body></html>
""" % locals()