system_assignation/imports/schedules_factory.py

39 lines
1.4 KiB
Python
Raw Normal View History

2020-06-09 14:07:47 -04:00
"""
2020-12-15 15:15:40 -05:00
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.
2020-06-09 14:07:47 -04:00
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
"""
2020-12-15 15:15:40 -05:00
from pathlib import Path
from imports.schedules.doe_idf import DoeIdf
2020-12-15 15:15:40 -05:00
class SchedulesFactory:
2020-06-15 11:38:18 -04:00
"""
2020-12-15 15:15:40 -05:00
SchedulesFactor class
2020-06-15 11:38:18 -04:00
"""
def __init__(self, handler, city, base_path=Path(Path(__file__).parent.parent / 'data/schedules')):
2020-12-15 15:15:40 -05:00
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.')
2020-06-30 16:14:39 -04:00
def _doe_idf(self):
2021-09-22 07:25:53 -04:00
"""
Enrich the city by using DOE IDF schedules as data source
"""
2021-09-16 13:45:27 -04:00
DoeIdf(self._city, self._base_path, 'doe_idf.xml')
def enrich(self):
2020-06-30 16:14:39 -04:00
"""
2021-09-22 07:25:53 -04:00
Enrich the city given to the class using the given schedule handler
2020-12-15 15:15:40 -05:00
:return: None
2020-06-30 16:14:39 -04:00
"""
2020-12-15 15:15:40 -05:00
getattr(self, self._handler, lambda: None)()