summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--alot/account.py4
-rw-r--r--alot/helper.py39
-rw-r--r--alot/settings/__init__.py (renamed from alot/settings.py)8
-rw-r--r--alot/settings/checks.py (renamed from alot/checks.py)0
-rw-r--r--alot/settings/errors.py (renamed from alot/errors.py)0
-rwxr-xr-xsetup.py2
6 files changed, 8 insertions, 45 deletions
diff --git a/alot/account.py b/alot/account.py
index 0e590953..8faee595 100644
--- a/alot/account.py
+++ b/alot/account.py
@@ -7,7 +7,7 @@ import os
import glob
import shlex
-import helper
+from alot.settings.utils import read_config
class SendingMailFailed(RuntimeError):
@@ -201,7 +201,7 @@ class AbookAddressBook(AddressBook):
DEFAULTSPATH = os.path.join(os.path.dirname(__file__), 'defaults')
self._spec = os.path.join(DEFAULTSPATH, 'abook_contacts.spec')
path = os.path.expanduser(path)
- self._config = helper.read_config(path, self._spec)
+ self._config = read_config(path, self._spec)
del(self._config['format'])
def get_contacts(self):
diff --git a/alot/helper.py b/alot/helper.py
index 7588e5aa..20751214 100644
--- a/alot/helper.py
+++ b/alot/helper.py
@@ -19,7 +19,7 @@ import StringIO
import logging
from configobj import ConfigObj, ConfigObjError, flatten_errors
from validate import Validator
-from alot.errors import ConfigError
+from alot.settings.errors import ConfigError
def safely_get(clb, E, on_error=''):
@@ -399,40 +399,3 @@ def humanize_size(size):
if size / factor < 1024:
return format_string % (float(size) / factor)
return format_string % (size / factor)
-
-
-def read_config(configpath=None, specpath=None, checks={}):
- """
- get a (validated) config object for given config file path.
-
- :param configpath: path to config-file
- :type configpath: str
- :param specpath: path to spec-file
- :type specpath: str
- :param checks: custom checks to use for validator.
- see `validate docs <http://www.voidspace.org.uk/python/validate.html>`_
- :type checks: dict str->callable,
- :rtype: `configobj.ConfigObj`
- """
- try:
- config = ConfigObj(infile=configpath, configspec=specpath,
- file_error=True, encoding='UTF8')
- except (ConfigObjError, IOError), e:
- raise ConfigError('Could not read "%s": %s' % (configpath, e))
-
- if specpath:
- validator = Validator()
- validator.functions.update(checks)
- results = config.validate(validator)
-
- if results != True:
- error_msg = 'Validation errors occurred:\n'
- for (section_list, key, _) in flatten_errors(config, results):
- if key is not None:
- msg = 'key "%s" in section "%s" failed validation'
- msg = msg % (key, ', '.join(section_list))
- else:
- msg = 'section "%s" is malformed' % ', '.join(section_list)
- error_msg += msg + '\n'
- raise ConfigError(error_msg)
- return config
diff --git a/alot/settings.py b/alot/settings/__init__.py
index 7fcea787..593fbae2 100644
--- a/alot/settings.py
+++ b/alot/settings/__init__.py
@@ -7,13 +7,13 @@ import urwid
from urwid import AttrSpec, AttrSpecError
from configobj import ConfigObj, Section
-from account import SendmailAccount, MatchSdtoutAddressbook, AbookAddressBook
+from alot.account import SendmailAccount, MatchSdtoutAddressbook, AbookAddressBook
-from alot.errors import ConfigError
-from alot.helper import read_config
+from errors import ConfigError
+from utils import read_config
from checks import mail_container
-DEFAULTSPATH = os.path.join(os.path.dirname(__file__), 'defaults')
+DEFAULTSPATH = os.path.join(os.path.dirname(__file__), '..', 'defaults')
class Theme(object):
diff --git a/alot/checks.py b/alot/settings/checks.py
index 693d3044..693d3044 100644
--- a/alot/checks.py
+++ b/alot/settings/checks.py
diff --git a/alot/errors.py b/alot/settings/errors.py
index 5409d315..5409d315 100644
--- a/alot/errors.py
+++ b/alot/settings/errors.py
diff --git a/setup.py b/setup.py
index 458fa96c..ec499efe 100755
--- a/setup.py
+++ b/setup.py
@@ -11,7 +11,7 @@ setup(name='alot',
author_email=alot.__author_email__,
url=alot.__url__,
license=alot.__copyright__,
- packages=['alot', 'alot.commands'],
+ packages=['alot', 'alot.commands', 'alot.settings'],
package_data={'alot': [
'defaults/alot.rc.spec',
'defaults/notmuch.rc.spec',