Skip to content

Commit

Permalink
handle typerror
Browse files Browse the repository at this point in the history
  • Loading branch information
astrowonk committed Aug 1, 2021
1 parent 8c0807c commit cf31596
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions gpxcsv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import gzip
import json

__VERSION__ = '0.2.9'
__VERSION__ = '0.2.10'


def _strip_ns_prefix(tree):
Expand All @@ -19,7 +19,7 @@ def _try_to_float(s):
"""convert string to float or leave as string"""
try:
return float(s)
except ValueError:
except (ValueError, TypeError):
return s


Expand Down Expand Up @@ -71,11 +71,11 @@ def _process_trackpoint(trackpoint, update_dict={}):
})
child_dict = {
x.tag: _try_to_float(x.text)
for x in trackpoint.getchildren() if x.tag != 'extensions'
for x in trackpoint.getchildren()
if x.tag != 'extensions'
}
final_dict = {
key: _try_to_float(val)
for key, val in trackpoint.attrib.items()
key: _try_to_float(val) for key, val in trackpoint.attrib.items()
}

final_dict.update(ext_dict)
Expand Down Expand Up @@ -167,8 +167,8 @@ def _list_to_csv(self, list_of_dicts, csv_file):

def gpxtolist(self, gpxfile):
"""Convert a gpx file to a list of dictionaries"""
if self.errors == 'ignore' and not (gpxfile.endswith('.gpx')
or gpxfile.endswith('.gpx.gz')):
if self.errors == 'ignore' and not (gpxfile.endswith('.gpx') or
gpxfile.endswith('.gpx.gz')):
return []
assert gpxfile.endswith('.gpx') or gpxfile.endswith(
'.gpx.gz'), 'File must be gpx or gpx.gz'
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="gpxcsv",
version="0.2.9",
version="0.2.10",
author="Marcos Huerta",
author_email="marcos@marcoshuerta.com",
description="Convert Garmin GPX file to CSV or simple JSON",
Expand Down

0 comments on commit cf31596

Please sign in to comment.