Skip to content

Commit

Permalink
Semi-fixed horrific config handling (#411)
Browse files Browse the repository at this point in the history
  • Loading branch information
dalmijn authored Nov 6, 2024
1 parent d40f38e commit 5d6102f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 27 deletions.
23 changes: 0 additions & 23 deletions hydromt_fiat/config.py

This file was deleted.

11 changes: 7 additions & 4 deletions hydromt_fiat/fiat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5d6102f

Please sign in to comment.