From 87cbe8ae7229acaecb1536de0dd9226c4e9d2a09 Mon Sep 17 00:00:00 2001 From: "Phyks (Lucas Verney)" Date: Mon, 11 Feb 2019 09:01:46 +0100 Subject: [PATCH] Add extra checks for OpenData works importer --- scripts/opendata/works.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/scripts/opendata/works.py b/scripts/opendata/works.py index 9580e51..a45d1f0 100755 --- a/scripts/opendata/works.py +++ b/scripts/opendata/works.py @@ -115,6 +115,10 @@ def preprocess_lille(data): def preprocess_loiret(data): out = [] + if not 'features' in data: + logging.warning('Invalid data for Loiret.') + return out + for item in data['features']: try: if 'paths' in item['geometry']: @@ -168,6 +172,10 @@ def preprocess_loiret(data): def preprocess_lyon(data): out = [] + if not 'features' in data: + logging.warning('Invalid data for Lyon.') + return out + for item in data['features']: try: new_item = { @@ -197,6 +205,10 @@ def preprocess_lyon(data): def preprocess_montpellier(data): out = [] + if not 'features' in data: + logging.warning('Invalid data for Montpellier.') + return out + for item in data['features']: try: new_item = { @@ -226,6 +238,10 @@ def preprocess_montpellier(data): def preprocess_nancy(data): out = [] + if not 'features' in data: + logging.warning('Invalid data for Nancy.') + return out + for item in data['features']: try: geometry = { @@ -289,6 +305,10 @@ def preprocess_paris(data): def preprocess_rennes(data): out = [] + if not 'features' in data: + logging.warning('Invalid data for Rennes.') + return out + for item in data['features']: try: new_item = { @@ -317,6 +337,10 @@ def preprocess_rennes(data): def preprocess_seine_saint_denis(data): out = [] + if not 'features' in data: + logging.warning('Invalid data for Seine-Saint-Denis.') + return out + for item in data['features']: try: new_item = { @@ -400,6 +424,10 @@ def preprocess_toulouse(data): def preprocess_versailles(data): out = [] + if not 'features' in data: + logging.warning('Invalid data for Versailles.') + return out + for item in data['features']: try: if 'paths' in item['geometry']: