Changeset 6994


Ignore:
Timestamp:
May 7, 2009, 1:56:19 PM (11 years ago)
Author:
ole
Message:

More robust read_polygon and meaningful error_message when files can't be read.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/utilities/polygon.py

    r6544 r6994  
    907907    polygon = []
    908908    for line in lines:
     909        if line.strip() == '': continue # Skip blank lines
    909910        fields = line.split(split)
    910         polygon.append( [float(fields[0]), float(fields[1])] )
     911
     912        try:
     913            x, y = float(fields[0]), float(fields[1])
     914        except:
     915            msg = 'Could not read line %s in file %s' %(line, filename)
     916            raise Exception, msg
     917           
     918        polygon.append([x, y])
    911919
    912920    return polygon
Note: See TracChangeset for help on using the changeset viewer.