From fc6c7e0313f36367eefc9ecb11d5db255cf3145a Mon Sep 17 00:00:00 2001 From: Nicolas Poirot Date: Wed, 10 May 2023 22:18:18 +0200 Subject: [PATCH] fix(backend): expand vars for rc and data location When passing an environment variable such as $XDG_CONFIG_HOME or $XDG_DATA_HOME to a TaskWarrior instance of the library, the variables are not expanded leading to ignoring rc_location or creating a path like '~/$XDG_DATA_HOME'. --- tasklib/backends.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tasklib/backends.py b/tasklib/backends.py index c6e87d5..18d13c4 100644 --- a/tasklib/backends.py +++ b/tasklib/backends.py @@ -95,7 +95,8 @@ def __init__(self, data_location=None, create=True, version_override=None): self.taskrc_location = None if taskrc_location: - self.taskrc_location = os.path.expanduser(taskrc_location) + self.taskrc_location = os.path.expandvars(taskrc_location) + self.taskrc_location = os.path.expanduser(self.taskrc_location) # If taskrc does not exist, pass / to use defaults and avoid creating # dummy .taskrc file by TaskWarrior @@ -121,6 +122,7 @@ def __init__(self, data_location=None, create=True, # Set data.location override if passed via kwarg if data_location is not None: + data_location = os.path.expandvars(data_location) data_location = os.path.expanduser(data_location) if create and not os.path.exists(data_location): os.makedirs(data_location)