43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
"""
|
|
Config
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
Copyright © 2023 Project Peter Yefi peteryefi@gmail.com
|
|
"""
|
|
import pickle
|
|
from pathlib import Path
|
|
import platform
|
|
import os
|
|
|
|
from hub.city_model_structure.city import City
|
|
from hub.exports.db_factory import DBFactory as CityExportFactory
|
|
from hub.imports.db_factory import DBFactory
|
|
|
|
|
|
class Config:
|
|
|
|
def __init__(self):
|
|
if platform.system() == 'Linux':
|
|
dotenv_path = Path('/usr/local/etc/hub/.env').resolve()
|
|
elif platform.system() == 'Windows':
|
|
dotenv_path = "{}/.env".format(os.path.expanduser('~'))
|
|
|
|
environment = 'TEST'
|
|
database_name = 'persistence_test'
|
|
|
|
self.export_db_factory = CityExportFactory(db_name=database_name, app_env=environment,
|
|
dotenv_path=dotenv_path)
|
|
self.import_db_factory = DBFactory(db_name=database_name, app_env=environment,
|
|
dotenv_path=dotenv_path)
|
|
|
|
def get_city(self, city_id) -> City:
|
|
city_obj = self.export_db_factory.get_city(city_id)
|
|
city = pickle.loads(city_obj.city)
|
|
for building in city.buildings:
|
|
building.heated = True
|
|
building.cooled = True
|
|
building.attic_heated = 0
|
|
building.basement_heated = 0
|
|
for surface in building.surfaces:
|
|
surface.swr = 0.2
|
|
return city
|