Пример #1
0
    def __init__(self, database, me_tag='to-me', tags_blacklist=[]):
        super().__init__(database, tags_blacklist=tags_blacklist)

        my_addresses = set()
        my_addresses.add(notmuch_settings.get('user', 'primary_email'))
        if notmuch_settings.has_option('user', 'other_email'):
            for other_email in notmuch_settings.get('user', 'other_email').split(';'):
                my_addresses.add(other_email)

        self.query = ' OR '.join('to:"%s"' % address
                                 for address in my_addresses)

        self.me_tag = me_tag
Пример #2
0
    def __init__(self, database, folder_blacklist='', folder_transforms='',
                 maildir_separator='.', folder_explicit_list='', folder_lowercases=''):
        super().__init__(database)

        self.__filename_pattern = '{mail_root}/(?P<maildirs>.*)/(cur|new)/[^/]+'.format(
            mail_root=notmuch_settings.get('database', 'path').rstrip('/'))
        self.__folder_explicit_list = set(shlex.split(folder_explicit_list))
        self.__folder_blacklist = set(folder_blacklist.split())
        self.__folder_transforms = self.__parse_transforms(folder_transforms)
        self.__folder_lowercases = folder_lowercases != ''
        self.__maildir_separator = maildir_separator
Пример #3
0
    def __init__(self, database, sent_tag='', to_transforms=''):
        super().__init__(database)

        my_addresses = set()
        my_addresses.add(notmuch_settings.get('user', 'primary_email'))
        if notmuch_settings.has_option('user', 'other_email'):
            for other_email in notmuch_settings.get('user',
                                                    'other_email').split(';'):
                my_addresses.add(other_email)

        self.query = ('(' + ' OR '.join('from:"%s"' % address
                                        for address in my_addresses) +
                      ') AND NOT (' +
                      ' OR '.join('to:"%s"' % address
                                  for address in my_addresses) + ')')

        self.sent_tag = sent_tag
        self.to_transforms = to_transforms
        if to_transforms:
            self.__email_to_tags = self.__build_email_to_tags(to_transforms)
Пример #4
0
    def _calculate_db_path(self):
        """
        Calculates the path to use for the database. Supports notmuch's
        methodology including falling back to $MAILDIR or $HOME/mail if a path
        is not specified and using $HOME/<path> if path is relative.
        """
        default_path = os.environ.get('MAILDIR', '{}/mail'.format(os.environ.get('HOME')))
        db_path = notmuch_settings.get('database', 'path', fallback=default_path)

        # If path is relative, notmuch prepends $HOME in front
        if not os.path.isabs(db_path):
            db_path = '{}/{}'.format(os.environ.get('HOME'), db_path)

        return db_path