diff --git a/hydromt_fiat/config.py b/hydromt_fiat/config.py deleted file mode 100644 index 1a3c5612..00000000 --- a/hydromt_fiat/config.py +++ /dev/null @@ -1,23 +0,0 @@ -import os -from typing import Union - -import tomli -import tomli_w -from hydromt_fiat.interface.config import IConfig - - -class Config(IConfig): - # TODO write now the pydantic models created are not used! - def load_file(self, filepath: Union[str, os.PathLike]): - """create Projection from toml file""" - - with open(filepath, mode="rb") as fp: - config = tomli.load(fp) - - return config - - @staticmethod - def save(config, filepath: Union[str, os.PathLike]): - """save Projection to a toml file""" - with open(filepath, "wb") as f: - tomli_w.dump(config, f) diff --git a/hydromt_fiat/fiat.py b/hydromt_fiat/fiat.py index 813da53b..039a1b71 100644 --- a/hydromt_fiat/fiat.py +++ b/hydromt_fiat/fiat.py @@ -10,13 +10,14 @@ import geopandas as gpd import hydromt import pandas as pd +import tomli +import tomli_w from hydromt.models.model_grid import GridModel from pyproj.crs import CRS from shapely.geometry import box import shutil from hydromt_fiat.api.data_types import Units -from hydromt_fiat.config import Config from hydromt_fiat.util import DATADIR from hydromt_fiat.spatial_joins import SpatialJoins from hydromt_fiat.workflows.exposure_vector import ExposureVector @@ -1216,8 +1217,9 @@ def read(self): def _configread(self, fn): """Parse Delft-FIAT configuration toml file to dict.""" # Read the fiat configuration toml file. - config = Config() - return config.load_file(fn) + with open(fn, mode="rb") as fp: + config = tomli.load(fp) + return config def read_tables(self): """Read the model tables for vulnerability and exposure data.""" @@ -1420,7 +1422,8 @@ def write_tables(self) -> None: def _configwrite(self, fn): """Write config to Delft-FIAT configuration toml file.""" # Save the configuration file. - Config().save(self.config, Path(self.root).joinpath("settings.toml")) + with open(fn, "wb") as f: + tomli_w.dump(self.config, f) # FIAT specific attributes and methods @property