2023-01-17 19:00:22 -05:00
|
|
|
"""
|
|
|
|
Config
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
|
|
Copyright © 2023 Project Peter Yefi peteryefi@gmail.com
|
|
|
|
"""
|
2023-02-21 10:47:17 -05:00
|
|
|
from pathlib import Path
|
|
|
|
|
2023-01-30 19:45:02 -05:00
|
|
|
from hub.exports.db_factory import DBFactory as CityExportFactory
|
|
|
|
from hub.imports.db_factory import DBFactory
|
2023-02-13 08:09:48 -05:00
|
|
|
import os
|
|
|
|
import pickle
|
2023-01-17 19:00:22 -05:00
|
|
|
|
|
|
|
|
|
|
|
class Config:
|
|
|
|
|
|
|
|
def __init__(self):
|
2023-02-21 10:47:17 -05:00
|
|
|
dotenv_path = Path('/usr/local/etc/hub/.env').resolve()
|
|
|
|
environment = 'TEST'
|
|
|
|
database_name = 'persistence_test'
|
2023-02-20 22:10:09 -05:00
|
|
|
|
2023-02-21 10:47:17 -05:00
|
|
|
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)
|
2023-01-17 19:00:22 -05:00
|
|
|
|
|
|
|
def get_city(self, city_id):
|
2023-02-13 08:09:48 -05:00
|
|
|
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
|