No need to validate() a city after critical error

This commit is contained in:
Alexey Zakharenkov 2019-07-02 16:33:35 +03:00
parent 5e347b09a1
commit 45a214892c
2 changed files with 9 additions and 9 deletions

View file

@ -17,12 +17,12 @@ from subway_io import (
write_recovery_data,
)
from subway_structure import (
CriticalValidationError,
download_cities,
find_transfers,
get_unused_entrances_geojson,
MODES_OVERGROUND,
MODES_RAPID,
StopperException,
)
@ -160,11 +160,11 @@ if __name__ == '__main__':
for c in cities:
try:
c.extract_routes()
except StopperException as e:
c.validate()
if c.is_good():
good_cities.append(c)
except CriticalValidationError as e:
logging.error("Critical validation error: %s", str(e))
c.validate()
if c.is_good():
good_cities.append(c)
logging.info('Finding transfer stations')
transfers = find_transfers(osm, cities)

View file

@ -32,9 +32,9 @@ NOWHERE_STOP = (0, 0) # too far away from any metro system
used_entrances = set()
class StopperException(Exception):
"""Is thrown if a critical validation error occurs
that prevents further validation."""
class CriticalValidationError(Exception):
"""Is thrown if an error occurs
that prevents further validation of a city."""
def el_id(el):
@ -711,7 +711,7 @@ class Route:
if 'stop' in m['role'] or 'platform' in m['role']:
city.error('{} {} {} for route relation is not in the dataset'.format(
m['role'], m['type'], m['ref']), relation)
raise StopperException(
raise CriticalValidationError(
'Stop or platform {} {} in relation {} '
'is not in the dataset for {}'.format(
m['type'], m['ref'], relation['id'], city.name))