def buildTable(): table = [["Date", "Time", "Period", "Time Left", "Score", "Team", "Player", "Status", "Action"]] for r in pbpTable[1:]: if len(r) < 4: break flag = r[1] != "" m = rePBP.match(r[1 if flag else 3]) if m is None: continue table.append( dateTime + \ [period] + \ [ r[0], r[2], teams[0 if flag else 1], best( [p[0] for p in players[0 if flag else 1]], withDefault(m.group(1), "").replace(",", ", ") ), withDefault(m.group(2), ""), withDefault(m.group(3), "") ] ) return table
def loadDateTime(): reDateTime = re.compile(r"^([^ ]+)(?: +(.+))?$") infoTable = loadTable(infofile) m = reDateTime.match(infoTable[1][0]) return [withDefault(m.group(1), default=""), withDefault(m.group(2), default="")]