from HTMLParser import HTMLParser, HTMLParseError

from state_machine import StateMachine
class TableParser(HTMLParser):
    def __init__(self):
        HTMLParser.__init__(self)
        self.state_machine = StateMachine()
        
    def handle_starttag(self, tag, attrs):
        self.state_machine.transition(tag, StateMachine.START_TAG)
    
    def handle_endtag(self, tag):
        self.state_machine.transition(tag, StateMachine.END_TAG)

    def handle_data(self, data):
        pass

@@ -135,16 +135,74 @@
 t__(self
+, header_row_fn=None, body_row_fn=None, footer_row_fn=None
 ):%0A     
@@ -274,16 +274,165 @@
 chine()%0A
+        self.header_row_fn = header_row_fn%0A        self.body_row_fn = body_row_fn%0A        self.footer_row_fn = footer_row_fn%0A        self.cells = %5B%5D%0A
         
@@ -650,51 +650,516 @@
 AG)%0A
-%0A    def handle_data(self, data):%0A        pass
+        if tag == 'tr':%0A            if self.state_machine.in_header() and self.header_row_fn:%0A                self.header_row_fn(self.cells)%0A            elif self.state_machine.in_body() and self.body_row_fn:%0A                self.body_row_fn(self.cells)%0A            elif self.state_machine.in_footer() and self.footer_row_fn:%0A                self.footer_row_fn(self.cells)%0A            self.cells = %5B%5D%0A%0A    def handle_data(self, data):%0A        if self.state_machine.in_cell():%0A            self.cells.append(data)
 %0A

Add callbacks for the completed rows to the table parser