# HG changeset patch # User Paul Boddie # Date 1424627678 -3600 # Node ID 256a5de072ecd6aed0671b8c88717520cdcd6be3 # Parent fa5107edac95db61df790d2f66b0be6fd3479a80 Made attribute interpretation more robust; removed redundant token stripping. diff -r fa5107edac95 -r 256a5de072ec ImprovedTableParser.py --- a/ImprovedTableParser.py Sat Feb 21 22:51:04 2015 +0100 +++ b/ImprovedTableParser.py Sun Feb 22 18:54:38 2015 +0100 @@ -95,7 +95,10 @@ column_usage = [] for column_attrs, text in columns: - rowspan = int(strip_token(column_attrs.get("rowspan", "1"))) + try: + rowspan = int(column_attrs.get("rowspan", "1")) + except ValueError: + rowspan = 1 if rowspan > 1: attrs = {} attrs.update(column_attrs) @@ -230,7 +233,10 @@ # Handle any previous column spanning other columns. if column_attrs.has_key("colspan"): - colspan = int(strip_token(column_attrs["colspan"])) + try: + colspan = int(column_attrs["colspan"]) + except ValueError: + colspan = 1 # Duplicate the current column as continuation # columns for as long as the colspan is defined.