Skip to content

Commit

Permalink
Fix QGIS plugin now that database entry is not in TOML (#826)
Browse files Browse the repository at this point in the history
This code gives an error in the QGIS plugin:

```python
    def _get_database_path_from_model_file(self) -> str:
        with open(self.path, "rb") as f:
            model_filename = tomllib.load(f)["database"]
            return str(Path(self.path).parent.joinpath(model_filename))
```

Because the database entry is no longer present in the TOML because of
#815.
  • Loading branch information
Huite authored Nov 24, 2023
1 parent c723e69 commit cd306a8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ribasim_qgis/widgets/dataset_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,10 @@ def load_geopackage(self) -> None:

def _get_database_path_from_model_file(self) -> str:
with open(self.path, "rb") as f:
model_filename = tomllib.load(f)["database"]
return str(Path(self.path).parent.joinpath(model_filename))
input_dir = Path(tomllib.load(f)["input_dir"])
# The .joinpath method (/) of pathlib.Path will take care of an absolute input_dir.
# No need to check it ourselves!
return str((Path(self.path).parent / input_dir / "database.gpkg").resolve())

def new_model(self) -> None:
"""Create a new Ribasim model file, and set it as the active dataset."""
Expand Down

0 comments on commit cd306a8

Please sign in to comment.