From 4b5383f1c7b71ed034ba85ffdbfcf2c66ad62e6f Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sat, 13 Apr 2024 00:12:43 +0200 Subject: [PATCH] Add home path getter to config --- novelwriter/config.py | 4 ++++ tests/test_base/test_base_config.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/novelwriter/config.py b/novelwriter/config.py index 1f817e0f..e9fab918 100644 --- a/novelwriter/config.py +++ b/novelwriter/config.py @@ -390,6 +390,10 @@ class Config: """Un-scale fixed gui sizes by the screen scale factor.""" return int(value/self.guiScale) + def homePath(self) -> Path: + """The user's home folder.""" + return self._homePath + def dataPath(self, target: str | None = None) -> Path: """Return a path in the data folder.""" if isinstance(target, str): diff --git a/tests/test_base/test_base_config.py b/tests/test_base/test_base_config.py index 5ec474fe..7c9cc88d 100644 --- a/tests/test_base/test_base_config.py +++ b/tests/test_base/test_base_config.py @@ -200,6 +200,9 @@ def testBaseConfig_Methods(fncPath): tstConf = Config() tstConf.initConfig(confPath=fncPath, dataPath=fncPath) + # Home Path + assert tstConf.homePath() == Path.home().absolute() + # Data Path assert tstConf.dataPath() == fncPath assert tstConf.dataPath("stuff") == fncPath / "stuff"