Exemplo n.º 1
0
    def add_message(self, path, tags=[], afterwards=None):
        """
        Adds a file to the notmuch index.

        :param path: path to the file
        :type path: str
        :param tags: tagstrings to add
        :type tags: list of str
        :param afterwards: callback to trigger after adding
        :type afterwards: callable or None
        """
        if self.ro:
            raise DatabaseROError()
        if not is_subdir_of(path, self.path):
            msg = 'message path %s ' % path
            msg += ' is not below notmuchs '
            msg += 'root path (%s)' % self.path
            raise DatabaseError(msg)
        else:
            self.writequeue.append(('add', afterwards, path, tags))
Exemplo n.º 2
0
    def add_message(self, path, tags=[], afterwards=None):
        """
        Adds a file to the notmuch index.

        :param path: path to the file
        :type path: str
        :param tags: tagstrings to add
        :type tags: list of str
        :param afterwards: callback to trigger after adding
        :type afterwards: callable or None
        """
        if self.ro:
            raise DatabaseROError()
        if not is_subdir_of(path, self.path):
            msg = 'message path %s ' % path
            msg += ' is not below notmuchs '
            msg += 'root path (%s)' % self.path
            raise DatabaseError(msg)
        else:
            self.writequeue.append(('add', afterwards, path, tags))
Exemplo n.º 3
0
 def test_relative_path_and_absolute_path_matching(self):
     superpath = 'a/b'
     subpath = os.path.join(os.getcwd(), 'a/b/c/d.rst')
     result = utils.is_subdir_of(subpath, superpath)
     self.assertTrue(result)
Exemplo n.º 4
0
 def test_both_paths_relative_not_matching(self):
     superpath = 'a/z'
     subpath = 'a/b/c/d.rst'
     result = utils.is_subdir_of(subpath, superpath)
     self.assertFalse(result)
Exemplo n.º 5
0
 def test_both_paths_absolute_matching(self):
     superpath = '/a/b'
     subpath = '/a/b/c/d.rst'
     result = utils.is_subdir_of(subpath, superpath)
     self.assertTrue(result)
Exemplo n.º 6
0
 def test_both_paths_relative_not_matching(self):
     superpath = 'a/z'
     subpath = 'a/b/c/d.rst'
     result = utils.is_subdir_of(subpath, superpath)
     self.assertFalse(result)
Exemplo n.º 7
0
 def test_both_paths_absolute_matching(self):
     superpath = '/a/b'
     subpath = '/a/b/c/d.rst'
     result = utils.is_subdir_of(subpath, superpath)
     self.assertTrue(result)
Exemplo n.º 8
0
 def test_relative_path_and_absolute_path_matching(self):
     superpath = 'a/b'
     subpath = os.path.join(os.getcwd(), 'a/b/c/d.rst')
     result = utils.is_subdir_of(subpath, superpath)
     self.assertTrue(result)