summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2012-02-25 18:45:37 +0000
committerPatrick Totzke <patricktotzke@gmail.com>2012-02-25 18:45:37 +0000
commitbaded452887862f1ce250d3da7eb4fdde09ecee3 (patch)
tree14f71c14121aeba065164817d6e43e2e096e98d0 /alot
parent300eb54f5e9b95d13f0a2babbe03ec380699ce85 (diff)
explicit abooks
This introduces a new syntax to specify addressbooks in account sections, which now contain an '[[[abook]]]' subsection: most important entry is 'type': the rest of the entries is validated according to this type. ATM the only working one is 'shellcommand', which makes alot instanciate a MatchSdtoutAddressbook. required for this type are the options 'command' and 'regexp'
Diffstat (limited to 'alot')
-rw-r--r--alot/defaults/alot.rc.spec16
-rw-r--r--alot/settings.py22
2 files changed, 26 insertions, 12 deletions
diff --git a/alot/defaults/alot.rc.spec b/alot/defaults/alot.rc.spec
index 6240fe57..fedc5f9e 100644
--- a/alot/defaults/alot.rc.spec
+++ b/alot/defaults/alot.rc.spec
@@ -155,10 +155,14 @@ user_agent = string(default='alot/$VERSION')
# signature_as_attachment is set to True
signature_filename = string(default=None)
- # command to lookup contacts.
- # If you specified `abook_command`, it will be used for tab completion in queries (to/from) and in message
- # composition. The command will be called with your prefix as only argument and its output is searched for name-email pairs.
- abook_command = string(default=None)
- # The regular expression used to match name/address pairs in the output of `abook_command`
- abook_regexp = string(default=None)
+ # address book for this account
+ [[[abook]]]
+ # type identifier for addressbook
+ type = option('shellcommand', default=None)
+ # command to lookup contacts.
+ # it will be called with the lookup prefix as only argument
+ command = string(default=None)
+
+ # regular expression used to match name/address pairs in the output of `command`
+ regexp = string(default=None)
diff --git a/alot/settings.py b/alot/settings.py
index 37e550ad..3b0bb563 100644
--- a/alot/settings.py
+++ b/alot/settings.py
@@ -197,12 +197,22 @@ class SettingsManager(object):
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'])
+ # create abook for this account
+ abook = accsec['abook']
+ logging.debug('abook defined: %s' % abook)
+ if abook['type'] == 'shellcommand':
+ cmd = abook['command']
+ regexp = abook['regexp']
+ logging.debug('abook: %s: %s' % (cmd, regexp))
+ if cmd is not None and regexp is not None:
+ args['abook'] = MatchSdtoutAddressbook(cmd,
+ match=regexp)
+ else:
+ msg = 'underspecified abook of type \'shellcommand\':'
+ msg += '\ncommand: %s\nregexp:%s' % (cmd, regexp)
+ raise ConfigError(msg)
+ else:
+ del(args['abook'])
cmd = args['sendmail_command']
del(args['sendmail_command'])