From 3a7dccff8cc37760fe98bf0211577b7f2ba81b21 Mon Sep 17 00:00:00 2001 From: guille Date: Fri, 24 Feb 2023 16:33:42 -0500 Subject: [PATCH] Set usage to unknown if it cannot be determined. --- hub/persistence/repositories/city.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hub/persistence/repositories/city.py b/hub/persistence/repositories/city.py index a1459c96..20f36882 100644 --- a/hub/persistence/repositories/city.py +++ b/hub/persistence/repositories/city.py @@ -60,8 +60,11 @@ class City(Repository): for building in city.buildings: object_usage = '' for internal_zone in building.internal_zones: - for usage in internal_zone.usages: - object_usage = f'{object_usage}{usage.name}_{usage.percentage} ' + if internal_zone is None or internal_zone.usages is None: + object_usage = 'Unknown' + else: + for usage in internal_zone.usages: + object_usage = f'{object_usage}{usage.name}_{usage.percentage} ' object_usage = object_usage.rstrip() db_city_object = CityObject(db_city.id, building.name,