summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2012-02-19 14:06:38 +0000
committerPatrick Totzke <patricktotzke@gmail.com>2012-02-19 14:06:38 +0000
commitdea500e99d73cb3be598fad63870f7f635209db9 (patch)
tree5c829cbe5c248dad89d13610b4f828e4ea72835c /alot
parent8e08502048203605fe89a30ba2c94647bf4efdf9 (diff)
parse accounts in SettingsManager
Diffstat (limited to 'alot')
-rw-r--r--alot/account.py3
-rw-r--r--alot/settings.py23
2 files changed, 24 insertions, 2 deletions
diff --git a/alot/account.py b/alot/account.py
index 106acc46..6caa30ac 100644
--- a/alot/account.py
+++ b/alot/account.py
@@ -53,8 +53,7 @@ class Account(object):
self.address = address
self.abook = abook
self.aliases = []
- if aliases:
- self.aliases = aliases.split(';')
+ self.aliases = aliases
self.realname = realname
self.gpg_key = gpg_key
self.signature = signature
diff --git a/alot/settings.py b/alot/settings.py
index e4b4180a..28c30231 100644
--- a/alot/settings.py
+++ b/alot/settings.py
@@ -11,6 +11,8 @@ from urwid import AttrSpec, AttrSpecError
from configobj import ConfigObj, ConfigObjError, flatten_errors, Section
from validate import Validator
+from account import SendmailAccount, MatchSdtoutAddressbook
+
from collections import OrderedDict
from ConfigParser import SafeConfigParser, ParsingError, NoOptionError
@@ -94,6 +96,8 @@ class SettingsManager(object):
self.read_config(alot_rc)
self.read_notmuch_config(notmuch_rc)
+ self._accounts = self.parse_accounts(self._config)
+
def read_notmuch_config(self, path):
spec = os.path.join(DEFAULTSPATH, 'notmuch.rc.spec')
@@ -114,6 +118,25 @@ class SettingsManager(object):
if isinstance(newbindings, Section):
self._bindings.merge(newbindings)
+ def parse_accounts(self, config):
+ accounts = []
+ if 'accounts' in config:
+ for acc in config['accounts'].sections:
+ accsec = config['accounts'][acc]
+ args = dict(config['accounts'][acc])
+
+ if 'abook_command' in accsec:
+ cmd = accsec['abook_command']
+ regexp = accsec['abook_regexp']
+ args['abook'] = MatchSdtoutAddressbook(cmd, match=regexp)
+ del(args['abook_command'])
+ del(args['abook_regexp'])
+
+ cmd = args['sendmail_command']
+ del(args['sendmail_command'])
+ accounts.append(SendmailAccount(cmd, **args))
+ return accounts
+
def get(self, key):
"""