hub/factories/weather_factory.py

39 lines
1.1 KiB
Python
Raw Normal View History

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
"""
from pathlib import Path
2020-10-29 08:16:48 -04:00
from factories.weather_feeders.dat_weather_parameters import DatWeatherParameters
from factories.weather_feeders.xls_weather_parameters import XlsWeatherParameters
2020-10-28 13:42:58 -04:00
class WeatherFactory:
"""
WeatherFactory class
"""
def __init__(self, handler, city, city_name, 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
self._base_path = base_path
self._city_name = city_name
2020-10-28 13:42:58 -04:00
self.factory()
def _dat(self):
2020-10-30 06:23:29 -04:00
DatWeatherParameters(self._city, self._base_path, self._city_name)
2020-10-28 13:42:58 -04:00
def _tmy(self):
raise Exception('Not implemented')
def _xls(self):
name = 'ISO_52016_1_BESTEST_ClimData_2016.08.24'
XlsWeatherParameters(self._city, self._base_path, name)
2020-10-28 13:42:58 -04:00
def factory(self):
"""
Enrich the city with the usage information
:return: None
"""
getattr(self, self._handler, lambda: None)()