Skip to content

Commit

Permalink
fixup! add a regionmapping to the config
Browse files Browse the repository at this point in the history
  • Loading branch information
coroa committed Apr 22, 2024
1 parent 4a1523f commit f7d0e77
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/concordia/settings.py
Expand Up @@ -4,6 +4,7 @@
import yaml
from attrs import define
from cattrs import structure, transform_error
from cattrs.errors import ClassValidationError


Pathy = str | Path
Expand Down Expand Up @@ -52,7 +53,7 @@ class Settings:
def resolve_paths(config):
def expand(path):
if path[0] == "$":
reference, relative = path.split("/", 1)
reference, relative = path[1:].split("/", 1)
return expand(config[reference]) / relative

return Path(path).expanduser()
Expand Down Expand Up @@ -80,5 +81,5 @@ def from_config(cls, config_path: Pathy = "config.yaml", **overwrites) -> Self:
# TODO might want to replace with merge for nested dictionaries
try:
return structure(cls.resolve_paths(config | overwrites), cls)
except Exception as exc:
except ClassValidationError as exc:
raise ValueError(", ".join(transform_error(exc, path="config"))) from None

0 comments on commit f7d0e77

Please sign in to comment.