2020-10-28 13:42:58 -04:00
|
|
|
"""
|
|
|
|
WeatherFactory retrieve the specific weather module for the given source format
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
|
|
Copyright © 2020 Project Author Pilar Monsalvete pilar_monsalvete@yahoo.es
|
|
|
|
"""
|
|
|
|
|
2020-10-29 07:40:40 -04:00
|
|
|
from pathlib import Path
|
2020-10-29 08:16:48 -04:00
|
|
|
from factories.weather_feeders.dat_weather_parameters import DatWeatherParameters
|
2020-10-28 13:42:58 -04:00
|
|
|
|
|
|
|
|
|
|
|
class WeatherFactory:
|
|
|
|
"""
|
|
|
|
WeatherFactory class
|
|
|
|
"""
|
|
|
|
|
|
|
|
# todo: modify full_path_weather to make it depending on "city"
|
2020-10-29 07:40:40 -04:00
|
|
|
def __init__(self, handler, city, base_path=Path(Path(__file__).parent.parent / 'data/weather')):
|
2020-10-28 13:42:58 -04:00
|
|
|
self._handler = '_' + handler.lower().replace(' ', '_')
|
|
|
|
self._city = city
|
2020-10-29 07:40:40 -04:00
|
|
|
self._base_path = base_path
|
2020-10-28 13:42:58 -04:00
|
|
|
self.factory()
|
|
|
|
|
|
|
|
def _dat(self):
|
2020-10-29 07:40:40 -04:00
|
|
|
DatWeatherParameters(self._city, Path(self._base_path / 'inseldb' + self._handler + '.dat'))
|
2020-10-28 13:42:58 -04:00
|
|
|
|
|
|
|
def _tmy(self):
|
|
|
|
raise Exception('Not implemented')
|
|
|
|
|
|
|
|
def factory(self):
|
|
|
|
"""
|
|
|
|
Enrich the city with the usage information
|
|
|
|
:return: None
|
|
|
|
"""
|
|
|
|
getattr(self, self._handler, lambda: None)()
|