blob: f72727568c8f21a0d5d1ecb548066898754500f0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
Accessing User Settings
=======================
.. module:: alot.settings
There are four types of user settings: notmuchs and alot's config
files, the hooks-file for user provided python code and the mailcap,
defining shellcomands as handlers for files of certain mime types.
Alot sets up :class:`FallbackConfigParser` objects to access the configs
of alot and notmuch`.
Hooks can be accessed via :meth:`AlotConfigParser.get_hook`
and MIME handlers can be looked up using :func:`alot.settings.get_mime_handler`.
+----------------+-----------------------------------+------------------------------+
| What | accessible via | Type |
+================+===================================+==============================+
| alot config | :obj:`alot.settings.config` | :class:`AlotConfigParser` |
+----------------+-----------------------------------+------------------------------+
| notmuch config | :obj:`alot.settings.notmuchconfig`| :class:`FallbackConfigParser`|
+----------------+-----------------------------------+------------------------------+
Through these objects you can access user settings (or their default values
if unset) in the following manner::
from alot.settings import config, notmuchconfig
# alot config
>>> config.getint('general', 'notify_timeout')
5
>>> config.getboolean('general', 'show_statusbar')
True
>>> config.getstringlist('general', 'displayed_headers')
[u'From', u'To', u'Cc', u'Bcc', u'Subject']
# notmuch config
>>> notmuchconfig.get('user', 'primary_email')
'patricktotzke@gmail.com'
>>> notmuchconfig.getboolean('maildir', 'synchronize_flags')
True
Hooks can be looked up using :meth:`AlotConfigParser.get_hook`.
They are user defined callables that expect to be called with the following parameters:
:ui: :class:`~alot.ui.UI` -- the initialized main component
:dbm: :class:`~alot.db.DBManager` -- :obj:`ui.dbman`
:aman: :class:`~alot.account.AccountManager` -- :obj:`ui.accountman`
:log: :class:`~logging.Logger` -- :obj:`ui.logger`
:config: :class:`AlotConfigParser` :obj:`alot.settings.config`
.. autoclass:: FallbackConfigParser
:members:
.. autoclass:: AlotConfigParser
:members:
.. autofunction:: get_mime_handler
|