inCell and inTable

This commit is contained in:
Edgar P. Burkhart 2020-09-20 21:26:53 +02:00
parent 4be55f963c
commit 27ee15ba2d
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227

View file

@ -31,6 +31,7 @@ class GoogleSheetsCalParser(HTMLParser):
""" """
def __init__(self): def __init__(self):
self.inTable = False self.inTable = False
self.inCell = False
self.row = -1 self.row = -1
self.column = -1 self.column = -1
HTMLParser.__init__(self) HTMLParser.__init__(self)
@ -42,11 +43,16 @@ class GoogleSheetsCalParser(HTMLParser):
self.column = -1 self.column = -1
elif tag == 'td': elif tag == 'td':
self.column += 1 self.column += 1
if not (self.row < 3 or (self.row - 2) % 11 < 2):
self.inCell = True
elif tag == 'tbody': elif tag == 'tbody':
self.inTable = True self.inTable = True
def handle_endtag(self, tag): def handle_endtag(self, tag):
... if tag == 'td':
self.inCell = False
elif tag == 'tbody':
self.inTable = False
def handle_data(self, data): def handle_data(self, data):
... ...