Skip to content

Commit

Permalink
added some error checking on table / row loads...
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Purcell committed Nov 18, 2014
1 parent f31d380 commit bf8ef43
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions gtfsdb/model/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,21 @@ def make_record(cls, row):
for k, v in row.items():
if isinstance(v, basestring):
row[k] = v.strip()
if (k not in cls.__table__.c):
del row[k]
elif not v:
row[k] = None
elif k.endswith('date'):
row[k] = datetime.datetime.strptime(v, '%Y%m%d').date()

try:
if k:
if (k not in cls.__table__.c):
del row[k]
elif not v:
row[k] = None
elif k.endswith('date'):
row[k] = datetime.datetime.strptime(v, '%Y%m%d').date()
else:
log.info("I've got issues with your GTFS {0} data. I'll continue, but expect more errors...".format(cls.__name__))
except Exception, e:
#import pdb; pdb.set_trace()
log.warning(e)

'''if this is a geospatially enabled database, add a geom'''
if hasattr(cls, 'geom') and hasattr(cls, 'add_geom_to_dict'):
cls.add_geom_to_dict(row)
Expand Down

0 comments on commit bf8ef43

Please sign in to comment.