system_assignation/factories/weather_factory.py

35 lines
1020 B
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
2020-10-28 13:42:58 -04:00
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')):
2020-10-28 13:42:58 -04:00
self._handler = '_' + handler.lower().replace(' ', '_')
self._city = city
self._base_path = base_path
2020-10-30 06:23:29 -04:00
self._city_name = 'new_york_city'
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 factory(self):
"""
Enrich the city with the usage information
:return: None
"""
getattr(self, self._handler, lambda: None)()