1# SPDX-License-Identifier: ISC 2# Copyright (c) Justus Winter <4winter@informatik.uni-hamburg.de> 3 4import os 5 6from afew.configparser import RawConfigParser 7 8notmuch_settings = RawConfigParser() 9 10 11def read_notmuch_settings(path=None): 12 if path == None: 13 path = os.environ.get('NOTMUCH_CONFIG', os.path.expanduser('~/.notmuch-config')) 14 15 with open(path) as fp: 16 notmuch_settings.read_file(fp) 17 18def write_notmuch_settings(path = None): 19 if path == None: 20 path = os.environ.get('NOTMUCH_CONFIG', os.path.expanduser('~/.notmuch-config')) 21 22 with open(path, 'w+') as fp: 23 notmuch_settings.write(fp) 24 25 26def get_notmuch_new_tags(): 27 # see issue 158 28 return filter(lambda x: x != 'unread', notmuch_settings.get_list('new', 'tags')) 29 30 31def get_notmuch_new_query(): 32 return '(%s)' % ' AND '.join('tag:%s' % tag for tag in get_notmuch_new_tags()) 33