From 2a8f34cfb9e5815ab0b57f64d6a6616da4edeefb Mon Sep 17 00:00:00 2001 From: Patrick Totzke Date: Wed, 17 Aug 2011 19:03:51 +0100 Subject: access notmuch's config via settings.notmuchconfig This adds a comdline option "-n" to specify the location of notmuch's config file and splits the CustomConfigparser --- alot/init.py | 7 ++++++- alot/settings.py | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/alot/init.py b/alot/init.py index 689e677d..e5a13a5b 100755 --- a/alot/init.py +++ b/alot/init.py @@ -31,7 +31,10 @@ def parse_args(): parser = argparse.ArgumentParser() parser.add_argument('-c', dest='configfile', default='~/.alot.rc', - help='config file') + help='alot\'s config file') + parser.add_argument('-n', dest='notmuchconfigfile', + default='~/.notmuch-config', + help='notmuch\'s config file') parser.add_argument('-C', dest='colours', type=int, choices=[1, 16, 256], @@ -61,6 +64,8 @@ def main(): #read config file configfilename = os.path.expanduser(args.configfile) settings.config.read(configfilename) + notmuchfile = os.path.expanduser(args.notmuchconfigfile) + settings.notmuchconfig.read(notmuchfile) settings.hooks.setup(settings.config.get('general', 'hooksfile')) # setup logging diff --git a/alot/settings.py b/alot/settings.py index 51a25827..b373016c 100644 --- a/alot/settings.py +++ b/alot/settings.py @@ -269,11 +269,16 @@ DEFAULTS = { } } +NOTMUCH_DEFAULTS = { + 'maildir': { + 'synchronize_flags': 'False', + }, +} -class CustomConfigParser(SafeConfigParser): + +class DefaultsConfigParser(SafeConfigParser): def __init__(self, defaults): self.defaults = defaults - self.hooks = None SafeConfigParser.__init__(self) self.optionxform = lambda x: x for sec in defaults.keys(): @@ -299,6 +304,11 @@ class CustomConfigParser(SafeConfigParser): value = self.get(section, option, **kwargs) return [s.strip() for s in value.split(',')] +class AlotConfigParser(DefaultsConfigParser): + def __init__(self, defaults): + DefaultsConfigParser.__init__(self, defaults) + self.hooks = None + def read(self, file): if not os.path.isfile(file): return @@ -388,7 +398,8 @@ class HookManager: return f -config = CustomConfigParser(DEFAULTS) +config = AlotConfigParser(DEFAULTS) +notmuchconfig = DefaultsConfigParser(NOTMUCH_DEFAULTS) hooks = HookManager() mailcaps = mailcap.getcaps() -- cgit v1.2.3