diff options
-rwxr-xr-x | alot/init.py | 29 | ||||
-rw-r--r-- | alot/settings.py | 26 | ||||
-rwxr-xr-x | setup.py | 4 |
3 files changed, 26 insertions, 33 deletions
diff --git a/alot/init.py b/alot/init.py index d3df252e..125f8877 100755 --- a/alot/init.py +++ b/alot/init.py @@ -3,7 +3,7 @@ import sys import logging import os -import settings +from settings import settings, ConfigError import ConfigParser from db import DBManager from ui import UI @@ -127,19 +127,19 @@ def main(): configfiles.insert(0, expanded_path) # locate notmuch config - notmuchfile = os.path.expanduser(args['notmuch-config']) + notmuchconfig = os.path.expanduser(args['notmuch-config']) - try: - # read the first alot config file we find - for configfilename in configfiles: - if os.path.exists(configfilename): - settings.config.read(configfilename) - break # use only the first - - # read notmuch config - settings.notmuchconfig.read(notmuchfile) + alotconfig = None + # read the first alot config file we find + for configfilename in configfiles: + if os.path.exists(configfilename): + alotconfig = configfilename + break # use only the first - except ConfigParser.Error, e: # exit on parse errors + try: + settings.read_config(alotconfig) + settings.read_config(notmuchconfig) + except ConfigError, e: # exit on parse errors sys.exit(e) # logging @@ -155,11 +155,10 @@ def main(): logging.basicConfig(level=numeric_loglevel, filename=logfilename, format=logformat) - #logging.debug(commands.COMMANDS) # get ourselves a database manager dbman = DBManager(path=args['mailindex-path'], ro=args['read-only']) - # get initial searchstring + # determine what to do try: if args.subCommand == 'search': query = ' '.join(args.subOptions.args) @@ -170,7 +169,7 @@ def main(): cmdstring = 'compose %s' % args.subOptions.as_argparse_opts() cmd = commands.commandfactory(cmdstring, 'global') else: - default_commandline = settings.settings.get('initial_command') + default_commandline = settings.get('initial_command') cmd = commands.commandfactory(default_commandline, 'global') except CommandParseError, e: sys.exit(e) diff --git a/alot/settings.py b/alot/settings.py index 3270f4d4..2292cadd 100644 --- a/alot/settings.py +++ b/alot/settings.py @@ -132,16 +132,15 @@ class SettingsManager(object): self.hooks = None theme_path = theme or os.path.join(DEFAULTSPATH, 'default.theme') - self.theme = Theme(theme_path) + self._theme = Theme(theme_path) self._bindings = read_config(os.path.join(DEFAULTSPATH, 'bindings')) self._config = ConfigObj() + self._accounts = None + self._accountmap = None self.read_config(alot_rc) self.read_notmuch_config(notmuch_rc) - self._accounts = self.parse_accounts(self._config) - self._accountmap = self._account_table(self._accounts) - def read_notmuch_config(self, path): """parse notmuch's config file from path""" spec = os.path.join(DEFAULTSPATH, 'notmuch.rc.spec') @@ -163,7 +162,10 @@ class SettingsManager(object): if isinstance(newbindings, Section): self._bindings.merge(newbindings) - def parse_accounts(self, config): + self._accounts = self._parse_accounts(self._config) + self._accountmap = self._account_table(self._accounts) + + def _parse_accounts(self, config): """ read accounts information from config @@ -247,7 +249,7 @@ class SettingsManager(object): :type name: str """ colours = int(self._config.get('colourmode')) - return self.theme.get_attribute(mode, name, colours) + return self._theme.get_attribute(mode, name, colours) def get_tagstring_representation(self, tag): """ @@ -259,8 +261,8 @@ class SettingsManager(object): """ colours = int(self._config.get('colourmode')) # default attributes: normal and focussed - default = self.theme.get_attribute('global', 'tag', colours) - default_f = self.theme.get_attribute('global', 'tag_focus', colours) + default = self._theme.get_attribute('global', 'tag', colours) + default_f = self._theme.get_attribute('global', 'tag_focus', colours) if tag in self._config['tags']: fg = self._config['tags'][tag]['fg'] or default.foreground bg = self._config['tags'][tag]['bg'] or default.background @@ -596,13 +598,7 @@ class AlotConfigParser(FallbackConfigParser): return cmdline -defaultconfig = os.path.join(DEFAULTSPATH, 'alot.rc') -defaultnotmuchconfig = os.path.join(DEFAULTSPATH, 'notmuch.rc') -config = AlotConfigParser() -config.read(defaultconfig) -notmuchconfig = FallbackConfigParser() -notmuchconfig.read(defaultnotmuchconfig) -settings = SettingsManager(os.path.join(DEFAULTSPATH, 'alot.rc.new'), defaultnotmuchconfig) +settings = SettingsManager() mailcaps = mailcap.getcaps() @@ -13,11 +13,9 @@ setup(name='alot', license=alot.__copyright__, packages=['alot', 'alot.commands'], package_data={'alot': [ - 'defaults/alot.rc', # only old-style default values - 'defaults/alot.rc.new', 'defaults/alot.rc.spec', 'defaults/notmuch.rc.spec', - 'defaults/default.theme', # default theme + 'defaults/default.theme', 'defaults/bindings', 'defaults/theme.spec', ]}, |