39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
"""
|
|
Construction catalog factory, publish the construction information
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
Copyright © 2022 Concordia CERC group
|
|
Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
|
"""
|
|
|
|
from pathlib import Path
|
|
from typing import TypeVar
|
|
from catalogs.construction.nrel_catalog import NrelCatalog
|
|
from catalogs.construction.nrcan_catalog import NrcanCatalog
|
|
Catalog = TypeVar('Catalog')
|
|
|
|
class ConstructionCatalogFactory:
|
|
def __init__(self, file_type, base_path=None):
|
|
if base_path is None:
|
|
base_path = Path(Path(__file__).parent.parent / 'data/construction')
|
|
self._catalog_type = '_' + file_type.lower()
|
|
self._path = base_path
|
|
|
|
def _nrel(self):
|
|
"""
|
|
Retrieve NREL catalog
|
|
"""
|
|
return NrelCatalog(self._path)
|
|
|
|
def _nrcan(self):
|
|
"""
|
|
Retrieve NRCAN catalog
|
|
"""
|
|
return NrcanCatalog(self._city, self._base_path)
|
|
|
|
@property
|
|
def catalog(self) -> Catalog:
|
|
"""
|
|
Enrich the city given to the class using the class given handler
|
|
:return: Catalog
|
|
"""
|
|
return getattr(self, self._catalog_type, lambda: None) |