""" SchedulesFactory retrieve the specific schedules module for the given standard This factory can only be called after calling the usage factory so the usage zones are created. SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2022 Concordia CERC group Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca """ from pathlib import Path from imports.schedules.doe_idf import DoeIdf class SchedulesFactory: """ SchedulesFactor class """ def __init__(self, handler, city, base_path=Path(Path(__file__).parent.parent / 'data/schedules')): self._handler = '_' + handler.lower().replace(' ', '_') self._city = city self._base_path = base_path for building in city.buildings: for internal_zone in building.internal_zones: if len(internal_zone.usage_zones) == 0: raise Exception('It seems that the schedule factory is being called before the usage factory. ' 'Please ensure that the usage factory is called first as the usage zones must be ' 'firstly generated.') def _doe_idf(self): """ Enrich the city by using DOE IDF schedules as data source """ DoeIdf(self._city, self._base_path, 'doe_idf.xml') def enrich(self): """ Enrich the city given to the class using the given schedule handler :return: None """ getattr(self, self._handler, lambda: None)()