VirtualMailManager/config.py
branchv0.6.x
changeset 326 8f8d9c4c8332
parent 322 94bd10e237e5
child 342 b0c971f943dc
--- a/VirtualMailManager/config.py	Thu Jul 29 04:01:43 2010 +0000
+++ b/VirtualMailManager/config.py	Thu Jul 29 19:14:19 2010 +0000
@@ -15,7 +15,8 @@
      ParsingError, RawConfigParser
 from cStringIO import StringIO# TODO: move interactive stff to cli
 
-from VirtualMailManager.common import exec_ok, get_unicode, is_dir, version_hex
+from VirtualMailManager.common import \
+     exec_ok, expand_path, get_unicode, lisdir, version_hex
 from VirtualMailManager.constants import CONF_ERROR
 from VirtualMailManager.errors import ConfigError, VMMError
 from VirtualMailManager.maillocation import known_format
@@ -411,6 +412,17 @@
         return not errors
 
 
+def is_dir(path):
+    """Check if the expanded path is a directory.  When the expanded path
+    is a directory the expanded path will be returned.  Otherwise a
+    ConfigValueError will be raised.
+    """
+    path = expand_path(path)
+    if lisdir(path):
+        return path
+    raise ConfigValueError(_(u"No such directory: %s") % get_unicode(path))
+
+
 def check_mailbox_format(format):
     """
     Check if the mailbox format *format* is supported.  When the *format*