-
Notifications
You must be signed in to change notification settings - Fork 0
/
plaintypes.py
48 lines (36 loc) · 1.06 KB
/
plaintypes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
class Cell(object):
def __init__(self, data):
self.expected = data
self.has_passed = False
def __repr__(self):
return self.expected
def __eq__(self, other):
return self.expected == other #.expected
def passed(self):
self.has_passed = True
def failed(self, actual):
self.has_failed = True
self.actual = actual
def error(self, message):
self.error_message = message
def missing(self):
self.is_missing = True
class Table(object):
def __init__(self, rows):
self.rows = rows
def cell(self, col, row):
return self.rows[row][col]
def name(self):
return str(self.rows[0][0])
def append_row(self, row):
self.rows.append(row)
def wiki_table_to_plain(table):
rows = []
for line in table.split('\n'):
row = line.lstrip().split('|')[1:-1]
if len(row):
cells = []
for cell in row:
cells.append(Cell(cell.lstrip().rstrip()))
rows.append(cells)
return rows