Set usage to unknown if it cannot be determined.

This commit is contained in:
Guille Gutierrez 2023-02-24 16:33:42 -05:00
parent 3d883fc068
commit 3a7dccff8c

View File

@ -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,