Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions afew/Database.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Database:

def __init__(self):
self.db_path = self._calculate_db_path()
self.mail_root = self._calculate_mail_root()
self.handle = None

def _calculate_db_path(self):
Expand All @@ -34,6 +35,19 @@ def _calculate_db_path(self):

return db_path

def _calculate_mail_root(self):
"""
Calculates the mail root directory. This is the directory that contains
the maildir directories. It is used to determine the relative path of
messages for notmuch.
"""
mail_root = notmuch_settings.get('database', 'mail_root', fallback=None)

if mail_root is None:
mail_root = self.db_path

return mail_root

def __enter__(self):
"""
Implements the context manager protocol.
Expand Down
2 changes: 1 addition & 1 deletion afew/filters/FolderNameFilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(self, database, folder_blacklist='', folder_transforms='',
super().__init__(database)

self.__filename_pattern = '{mail_root}/(?P<maildirs>.*)/(cur|new)/[^/]+'.format(
mail_root=database.db_path.rstrip('/'))
mail_root=database.mail_root.rstrip('/'))
self.__folder_explicit_list = set(shlex.split(folder_explicit_list))
self.__folder_blacklist = set(shlex.split(folder_blacklist))
self.__folder_transforms = self.__parse_transforms(folder_transforms)
Expand Down