VirtualMailManager/config.py
branchv0.6.x
changeset 326 8f8d9c4c8332
parent 322 94bd10e237e5
child 342 b0c971f943dc
equal deleted inserted replaced
325:06c0457036a0 326:8f8d9c4c8332
    13 from ConfigParser import \
    13 from ConfigParser import \
    14      Error, MissingSectionHeaderError, NoOptionError, NoSectionError, \
    14      Error, MissingSectionHeaderError, NoOptionError, NoSectionError, \
    15      ParsingError, RawConfigParser
    15      ParsingError, RawConfigParser
    16 from cStringIO import StringIO# TODO: move interactive stff to cli
    16 from cStringIO import StringIO# TODO: move interactive stff to cli
    17 
    17 
    18 from VirtualMailManager.common import exec_ok, get_unicode, is_dir, version_hex
    18 from VirtualMailManager.common import \
       
    19      exec_ok, expand_path, get_unicode, lisdir, version_hex
    19 from VirtualMailManager.constants import CONF_ERROR
    20 from VirtualMailManager.constants import CONF_ERROR
    20 from VirtualMailManager.errors import ConfigError, VMMError
    21 from VirtualMailManager.errors import ConfigError, VMMError
    21 from VirtualMailManager.maillocation import known_format
    22 from VirtualMailManager.maillocation import known_format
    22 from VirtualMailManager.password import verify_scheme as _verify_scheme
    23 from VirtualMailManager.password import verify_scheme as _verify_scheme
    23 
    24 
   409             if missing:
   410             if missing:
   410                 self.__missing[section] = missing
   411                 self.__missing[section] = missing
   411         return not errors
   412         return not errors
   412 
   413 
   413 
   414 
       
   415 def is_dir(path):
       
   416     """Check if the expanded path is a directory.  When the expanded path
       
   417     is a directory the expanded path will be returned.  Otherwise a
       
   418     ConfigValueError will be raised.
       
   419     """
       
   420     path = expand_path(path)
       
   421     if lisdir(path):
       
   422         return path
       
   423     raise ConfigValueError(_(u"No such directory: %s") % get_unicode(path))
       
   424 
       
   425 
   414 def check_mailbox_format(format):
   426 def check_mailbox_format(format):
   415     """
   427     """
   416     Check if the mailbox format *format* is supported.  When the *format*
   428     Check if the mailbox format *format* is supported.  When the *format*
   417     is supported it will be returned, otherwise a `ConfigValueError` will
   429     is supported it will be returned, otherwise a `ConfigValueError` will
   418     be raised.
   430     be raised.