# HG changeset patch # User Ludovic Chabant # Date 1560291260 25200 # Node ID 40a40305c4e144ed4b3661e3c1700ac207c33873 # Parent 4ea64255eadf547978e4cf45e2be28f7e1ebba61 config: Support environment variables in theme directories. diff -r 4ea64255eadf -r 40a40305c4e1 piecrust/pathutil.py --- a/piecrust/pathutil.py Tue Jun 11 15:12:47 2019 -0700 +++ b/piecrust/pathutil.py Tue Jun 11 15:14:20 2019 -0700 @@ -62,3 +62,9 @@ os.makedirs(path, mode=mode, exist_ok=True) except OSError: pass + + +def expandall(path): + path = os.path.expandvars(path) + path = os.path.expanduser(path) + return path diff -r 4ea64255eadf -r 40a40305c4e1 piecrust/themes/base.py --- a/piecrust/themes/base.py Tue Jun 11 15:12:47 2019 -0700 +++ b/piecrust/themes/base.py Tue Jun 11 15:14:20 2019 -0700 @@ -34,13 +34,13 @@ return None # Get the list of directories in which themes are installed. + from piecrust.pathutil import expandall dirs = [] themes_dirs = site_config.get('themes_dirs', []) if isinstance(themes_dirs, str): - dirs.append(os.path.join(self.root_dir, - os.path.expanduser(themes_dirs))) + dirs.append(os.path.join(self.root_dir, expandall(themes_dirs))) else: - dirs += [os.path.join(self.root_dir, os.path.expanduser(p)) + dirs += [os.path.join(self.root_dir, expandall(p)) for p in themes_dirs] # Add the default `themes` directory.