2020-06-09 14:07:47 -04:00
|
|
|
"""
|
|
|
|
UsageFactory retrieve the specific usage module for the given region
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
|
|
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
|
|
|
"""
|
2021-01-06 16:42:38 -05:00
|
|
|
from pathlib import Path
|
2021-03-02 18:57:09 -05:00
|
|
|
from imports.usage_feeders.de_usage_parameters import DeUsageParameters
|
|
|
|
from imports.usage_feeders.us_new_york_city_usage_parameters import UsNewYorkCityUsageParameters
|
|
|
|
from imports.usage_feeders.ca_usage_parameters import CaUsageParameters
|
2020-05-18 13:25:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
class UsageFactory:
|
2020-06-11 16:55:52 -04:00
|
|
|
"""
|
|
|
|
UsageFactory class
|
|
|
|
"""
|
2021-01-06 16:42:38 -05:00
|
|
|
def __init__(self, handler, city, base_path=Path(Path(__file__).parent.parent / 'data/usage')):
|
2020-06-11 16:55:52 -04:00
|
|
|
self._handler = '_' + handler.lower().replace(' ', '_')
|
2020-05-18 13:25:08 -04:00
|
|
|
self._city = city
|
2021-01-06 16:42:38 -05:00
|
|
|
self._base_path = base_path
|
2020-05-18 13:25:08 -04:00
|
|
|
self.factory()
|
|
|
|
|
2020-06-26 21:10:56 -04:00
|
|
|
def _us_new_york(self):
|
2021-01-07 18:53:26 -05:00
|
|
|
UsNewYorkCityUsageParameters(self._city, self._base_path).enrich_buildings()
|
2020-05-18 13:25:08 -04:00
|
|
|
|
2020-06-11 16:55:52 -04:00
|
|
|
def _ca(self):
|
2021-01-07 18:12:13 -05:00
|
|
|
CaUsageParameters(self._city, self._base_path).enrich_buildings()
|
2020-05-18 13:25:08 -04:00
|
|
|
|
2020-06-11 16:55:52 -04:00
|
|
|
def _de(self):
|
2021-01-07 18:53:26 -05:00
|
|
|
DeUsageParameters(self._city, self._base_path).enrich_buildings()
|
2020-05-18 13:25:08 -04:00
|
|
|
|
2020-06-11 16:55:52 -04:00
|
|
|
def _es(self):
|
2020-05-18 13:25:08 -04:00
|
|
|
raise Exception('Not implemented')
|
|
|
|
|
|
|
|
def factory(self):
|
2020-06-11 16:55:52 -04:00
|
|
|
"""
|
|
|
|
Enrich the city with the usage information
|
|
|
|
:return: None
|
|
|
|
"""
|
2020-05-18 13:25:08 -04:00
|
|
|
getattr(self, self._handler, lambda: None)()
|