18
18
19
19
columns = ['name' , 'authors' , 'beginner' , 'proof' , 'tlc' , 'pcal' , 'apalache' ]
20
20
21
- def get_column (row , index ):
21
+ def get_column (row , col_name ):
22
22
'''
23
23
Gets the cell of the given column in the given row.
24
24
'''
25
- return row .children [columns .index (index )].children [0 ]
25
+ return row .children [columns .index (col_name )].children [0 ]
26
26
27
- def remove_column (table , col_index ):
27
+ def remove_column (table , col_name ):
28
28
'''
29
29
Removes the column of the given index from the table.
30
30
'''
31
- index = columns .index (col_index )
31
+ index = columns .index (col_name )
32
32
table .header .children .pop (index )
33
33
table .column_align .pop (index )
34
34
for row in table .children :
35
35
row .children .pop (index )
36
36
37
- def blank_column (table , col_index ):
37
+ def blank_column (table , col_name ):
38
38
'''
39
39
Removes all data in the given column.
40
40
'''
41
- index = columns .index (col_index )
41
+ index = columns .index (col_name )
42
42
for row in table .children :
43
43
row .children [index ].children = []
44
44
45
- def swap_columns (table , first_col_index , second_col_index ):
45
+ def duplicate_column (table , col_name ):
46
+ '''
47
+ Duplicates the given column.
48
+ '''
49
+ index = columns .index (col_name )
50
+ table .header .children .insert (index , table .header .children [index ])
51
+ table .column_align .insert (index , table .column_align [index ])
52
+ for row in table .children :
53
+ row .children .insert (index , row .children [index ])
54
+
55
+ def swap_columns (table , first_col_name , second_col_name ):
46
56
'''
47
57
Swaps two columns in a table.
48
58
'''
49
- first = columns .index (first_col_index )
50
- second = columns .index (second_col_index )
59
+ first = columns .index (first_col_name )
60
+ second = columns .index (second_col_name )
51
61
table .header .children [second ], table .header .children [first ] = table .header .children [first ], table .header .children [second ]
52
62
table .column_align [second ], table .column_align [first ] = table .column_align [first ], table .column_align [second ]
53
63
for row in table .children :
54
64
row .children [second ], row .children [first ] = row .children [first ], row .children [second ]
55
65
56
-
57
66
def format_table (table ):
58
67
'''
59
68
All table transformations should go here.
@@ -65,8 +74,9 @@ def format_document(document):
65
74
All document transformations should go here.
66
75
'''
67
76
# Gets table of local specs
68
- table = next ((child for child in document .children if isinstance (child , Table )))
69
- format_table (table )
77
+ local_table , remote_table = [child for child in document .children if isinstance (child , Table )]
78
+ #format_table(local_table)
79
+ #format_table(remote_table)
70
80
71
81
# Read, format, write
72
82
# Need to both parse & render within same MarkdownRenderer context to preserve other formatting
0 commit comments