changeset 1157:40a40305c4e1

config: Support environment variables in theme directories.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 11 Jun 2019 15:14:20 -0700
parents 4ea64255eadf
children 5762a0b821ac
files piecrust/pathutil.py piecrust/themes/base.py
diffstat 2 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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.