changeset 76:7c55fb368d0b

web: expand the cachedir value of of staticweb.cfg
author Bernhard Herzog <bh@intevation.de>
date Tue, 17 Apr 2007 12:29:24 +0200
parents 6c4a4b8d6729
children f0aa5a8af056
files demostaticweb.cfg publishstaticweb.py
diffstat 2 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/demostaticweb.cfg	Tue Apr 17 11:52:28 2007 +0200
+++ b/demostaticweb.cfg	Tue Apr 17 12:29:24 2007 +0200
@@ -34,5 +34,9 @@
 publish_dir: /tmp/treepkg-status
 
 # local cache directory.  publishstaticweb.py may delete it and its
-# contents.
-cachedir: /tmp/treepkg-status
+# contents.  The value is passed through the python functions
+# os.path.expanduser and os.path.expandvars, so references to home
+# directories of the form ~ or ~user at the beginning of the value and
+# environment variable references of the form $VAR or ${VAR} are
+# expanded.
+cachedir: /tmp/${USER}/treepkg-status-cache
--- a/publishstaticweb.py	Tue Apr 17 11:52:28 2007 +0200
+++ b/publishstaticweb.py	Tue Apr 17 12:29:24 2007 +0200
@@ -19,11 +19,18 @@
 def remove_trailing_slashes(s):
     return s.rstrip("/")
 
+def expand_filename(filename):
+    """
+    Applies os.path.expanduser and os.path.expandvars to filename
+    """
+    return os.path.expandvars(os.path.expanduser(filename))
+
 staticweb_desc = ["build_user", "build_host", "build_create",
                   ("build_dir", remove_trailing_slashes),
                   "publish_user", "publish_host",
                   ("publish_dir", remove_trailing_slashes),
-                  ("cachedir", remove_trailing_slashes)]
+                  ("cachedir",
+                   lambda s: expand_filename(remove_trailing_slashes(s)))]
 
 def read_config(filename):
     parser = SafeConfigParser()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)