From: Aiwota Programmer Date: Mon, 11 Sep 2006 07:02:35 +0000 (+0900) Subject: response html parser. X-Git-Tag: v0.1~9 X-Git-Url: http://git.sourceforge.jp/view?p=fukui-no-namari%2Ffukui-no-namari.git;a=commitdiff_plain;h=a7493c2fb3c86abaea541a02caa61a9930132554 response html parser. --- diff --git a/src/FukuiNoNamari/submit_window.py b/src/FukuiNoNamari/submit_window.py index b06ea91..6524ab5 100644 --- a/src/FukuiNoNamari/submit_window.py +++ b/src/FukuiNoNamari/submit_window.py @@ -55,12 +55,19 @@ class ConfirmationHTMLParser(HTMLParserEx): self.message = "" self.inputs = [] self.complete = False + self.title = "" + self.in_head = False + self.in_title = False def handle_starttag(self, tag, attr): if tag == "br": self.message += "\n" elif tag == "input": self.inputs.append(dict(attr)) + elif tag == "title": + self.in_title = True + elif tag == "head": + self.in_head = True elif tag == "meta": attr_dict = dict(attr) if "http-equiv" in attr_dict \ @@ -68,13 +75,19 @@ class ConfirmationHTMLParser(HTMLParserEx): self.complete = True def handle_endtag(self, tag): - pass + if tag == "title": + self.in_title = False + elif tag == "head": + self.in_head = False def handle_comment(self, comment): - print comment.strip() + pass def handle_data(self, data): - self.message += data + if self.in_title: + self.title = data + elif not self.in_head: + self.message += data.rstrip() def handle_charref(self, ref): data = None @@ -170,6 +183,8 @@ class WinWrap: window = gtk.Window() if not p.complete: window.set_default_size(500, 500) + if p.title: + window.set_title(p.title) textview = gtk.TextView() textview.set_wrap_mode(gtk.WRAP_CHAR) textview.set_editable(False)