Skip to content
This repository was archived by the owner on Aug 25, 2024. It is now read-only.

Commit 34f6ddf

Browse files
authored
model: Expand homedir for directory in model configs
Fixes: #487 Signed-off-By: John Andersen <[email protected]>
1 parent 90f1aaa commit 34f6ddf

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2222
incorrectly.
2323
- `operations_parameter_set_pairs` moved to `MemoryOrchestratorContext`
2424
- Ignore generated files in `docs/plugins/`
25+
- Treat `"~"` as the the home directory rather than a literal
2526
- Windows support by selecting `asyncio.ProactorEventLoop` and not using
2627
`asyncio.FastChildWatcher`.
2728

dffml/model/model.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,13 @@ def __init__(self, config):
8484
# TODO Just in case its a string. We should make it so that on
8585
# instantiation of an @config we convert properties to their correct
8686
# types.
87-
if isinstance(getattr(self.config, "directory", None), str):
88-
self.config.directory = pathlib.Path(self.config.directory)
87+
directory = getattr(self.config, "directory", None)
88+
if isinstance(directory, str):
89+
directory = pathlib.Path(directory)
90+
if isinstance(directory, pathlib.Path):
91+
# to treat "~" as the the home directory rather than a literal
92+
directory = directory.expanduser().resolve()
93+
self.config.directory = directory
8994

9095
def __call__(self) -> ModelContext:
9196
self._make_config_directory()

0 commit comments

Comments
 (0)