ImprovedTableParser

Changeset

42:256a5de072ec
2015-02-22 Paul Boddie raw files shortlog changelog graph Made attribute interpretation more robust; removed redundant token stripping.
ImprovedTableParser.py (file)
     1.1 --- a/ImprovedTableParser.py	Sat Feb 21 22:51:04 2015 +0100
     1.2 +++ b/ImprovedTableParser.py	Sun Feb 22 18:54:38 2015 +0100
     1.3 @@ -95,7 +95,10 @@
     1.4                          column_usage = []
     1.5  
     1.6                          for column_attrs, text in columns:
     1.7 -                            rowspan = int(strip_token(column_attrs.get("rowspan", "1")))
     1.8 +                            try:
     1.9 +                                rowspan = int(column_attrs.get("rowspan", "1"))
    1.10 +                            except ValueError:
    1.11 +                                rowspan = 1
    1.12                              if rowspan > 1:
    1.13                                  attrs = {}
    1.14                                  attrs.update(column_attrs)
    1.15 @@ -230,7 +233,10 @@
    1.16      # Handle any previous column spanning other columns.
    1.17  
    1.18      if column_attrs.has_key("colspan"):
    1.19 -        colspan = int(strip_token(column_attrs["colspan"]))
    1.20 +        try:
    1.21 +            colspan = int(column_attrs["colspan"])
    1.22 +        except ValueError:
    1.23 +            colspan = 1
    1.24  
    1.25          # Duplicate the current column as continuation
    1.26          # columns for as long as the colspan is defined.