summer_course_2024/factories/weather_factory.py
Pilar e9dd9c2221 eliminated many parameters from configuration.ini that will now depend on the workflow
added example iso 52016-1:2017
added new weather format defined in iso 52016-1:2017 (xls)
2021-01-11 17:11:50 -05:00

39 lines
1.1 KiB
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
from factories.weather_feeders.xls_weather_parameters import XlsWeatherParameters
class WeatherFactory:
"""
WeatherFactory class
"""
def __init__(self, handler, city, city_name, base_path=Path(Path(__file__).parent.parent / 'data/weather')):
self._handler = '_' + handler.lower().replace(' ', '_')
self._city = city
self._base_path = base_path
self._city_name = city_name
self.factory()
def _dat(self):
DatWeatherParameters(self._city, self._base_path, self._city_name)
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)
def factory(self):
"""
Enrich the city with the usage information
:return: None
"""
getattr(self, self._handler, lambda: None)()