Skip to content

Commit

Permalink
optional ignoring data errors
Browse files Browse the repository at this point in the history
  • Loading branch information
MKuranowski committed May 11, 2020
1 parent 386d4d8 commit c33cbe1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions pyroutelib3.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"Modifications: Copyright 2017-2020, Mikolaj Kuranowski"
__credits__ = ["Oliver White", "Mikolaj Kuranowski"]
__license__ = "GPL v3"
__version__ = "1.6.0"
__version__ = "1.6.1"
__maintainer__ = "Mikolaj Kuranowski"
__email__ = "".join(chr(i) for i in [109, 107, 117, 114, 97, 110, 111, 119, 115, 107, 105, 64,
103, 109, 97, 105, 108, 46, 99, 111, 109])
Expand Down Expand Up @@ -135,7 +135,7 @@ def _flatternAndRemoveDupes(x):
class Datastore:
"""Object for storing routing data"""
def __init__(self, transport, localfile=False, localfileType="xml",
expire_data=30, storage_class=dict):
expire_data=30, storage_class=dict, ignoreDataErrs=True):
"""Initialise an OSM-file parser"""
# Routing data
self.routing = storage_class()
Expand All @@ -147,6 +147,7 @@ def __init__(self, transport, localfile=False, localfileType="xml",
self.tiles = storage_class()
self.expire_data = 86400 * expire_data # expire_data is in days, we need seconds
self.localFile = bool(localfile)
self.ignoreDataErrs = ignoreDataErrs

# verify localFileType
if localfileType not in {"xml", "gz", "bz2", "pbf"}:
Expand Down Expand Up @@ -325,8 +326,11 @@ def loadOsm(self, file, filetype="xml"):

self.storeRestriction(relId, restrictionType, nodes)

except (KeyError, AssertionError, IndexError):
continue
except (KeyError, AssertionError, IndexError, ValueError):
if self.ignoreDataErrs:
continue
else:
raise

def storeRestriction(self, relId, restrictionType, members):
# Order members of restriction
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
name="pyroutelib3",
py_modules=["pyroutelib3"],
license="GPL v3",
version="1.6.0",
version="1.6.1",
description="Library for simple routing on OSM data",
long_description=readme,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit c33cbe1

Please # to comment.