city_retrofit/factories/weather_factory.py
2020-10-29 08:16:48 -04:00

35 lines
1009 B
Python

"""
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
"""
from pathlib import Path
from factories.weather_feeders.dat_weather_parameters import DatWeatherParameters
class WeatherFactory:
"""
WeatherFactory class
"""
# todo: modify full_path_weather to make it depending on "city"
def __init__(self, handler, city, base_path=Path(Path(__file__).parent.parent / 'data/weather')):
self._handler = '_' + handler.lower().replace(' ', '_')
self._city = city
self._base_path = base_path
self.factory()
def _dat(self):
DatWeatherParameters(self._city, Path(self._base_path / 'inseldb' + self._handler + '.dat'))
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)()