From 91a25d1f5bb63960c64977d3710c4059f9695574 Mon Sep 17 00:00:00 2001 From: Sanj Date: Thu, 2 Feb 2012 19:09:29 +0530 Subject: [PATCH] edit import_atlas to use Route if routeMapping.json does not contain mapping --- chaloBEST/imports/import_atlas.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/chaloBEST/imports/import_atlas.py b/chaloBEST/imports/import_atlas.py index b990151..782adc9 100644 --- a/chaloBEST/imports/import_atlas.py +++ b/chaloBEST/imports/import_atlas.py @@ -123,12 +123,19 @@ def importUniqueRoutes(): stopMapping = {} #FIXME stopErrors = [] #This should ideally never happen, and any errors here are bad and would indicate problems with the fuzzy matching logic, most likely. for route in data.keys(): - routeCode = routeMapping[route] - try: - routeObj = Route.objects.get(code=routeCode) - except: - routeDoesNotExistErrors.append({'routeCode': routeCode, 'routeAlias': route}) - continue + if routeMapping.has_key(route): + routeCode = routeMapping[route] + try: + routeObj = Route.objects.get(code=routeCode) + except: + routeDoesNotExistErrors.append({'routeCode': routeCode, 'routeAlias': route}) + continue + else: + try: + routeObj = Route.objects.get(alias=route) + except: + routeDoesNotExistErrors.append({'routeAlias': route}) + for unique_route in data[route]: thisRoute = unique_route #FIXME try: