]> git.notmuchmail.org Git - notmuch/blobdiff - bindings/python/notmuch/database.py
python: Improve the docstring of Database.get_directory
[notmuch] / bindings / python / notmuch / database.py
index d8413671ad5610938909540076042e602d8eac6e..bef9720fcc7105599c4c7be21059659bb9c7f5a2 100644 (file)
@@ -122,7 +122,8 @@ class Database(object):
     _create.argtypes = [c_char_p]
     _create.restype = NotmuchDatabaseP
 
-    def __init__(self, path=None, create=False, mode=0):
+    def __init__(self, path = None, create = False,
+                 mode = MODE.READ_ONLY):
         """If *path* is `None`, we will try to read a users notmuch
         configuration and use his configured database. The location of the
         configuration file can be specified through the environment variable
@@ -344,14 +345,12 @@ class Database(object):
               of database (see :meth:`get_path`), or else should be an absolute
               path with initial components that match the path of 'database'.
         :returns: :class:`Directory` or raises an exception.
-        :raises:
-            :exc:`NotmuchError` with :attr:`STATUS`.FILE_ERROR
-                    If path is not relative database or absolute with initial
-                    components same as database.
+        :raises: :exc:`FileError` if path is not relative database or absolute
+                 with initial components same as database.
         """
         self._assert_db_is_initialized()
         # sanity checking if path is valid, and make path absolute
-        if path[0] == os.sep:
+        if path and path[0] == os.sep:
             # we got an absolute path
             if not path.startswith(self.get_path()):
                 # but its initial components are not equal to the db path
@@ -365,7 +364,7 @@ class Database(object):
         dir_p = Database._get_directory(self._db, _str(path))
 
         # return the Directory, init it with the absolute path
-        return Directory(_str(abs_dirpath), dir_p, self)
+        return Directory(abs_dirpath, dir_p, self)
 
     _add_message = nmlib.notmuch_database_add_message
     _add_message.argtypes = [NotmuchDatabaseP, c_char_p,
@@ -639,7 +638,7 @@ class Directory(object):
 
     def __init__(self, path, dir_p, parent):
         """
-        :param path:   The absolute path of the directory object as unicode.
+        :param path:   The absolute path of the directory object.
         :param dir_p:  The pointer to an internal notmuch_directory_t object.
         :param parent: The object this Directory is derived from
                        (usually a :class:`Database`). We do not directly use
@@ -647,7 +646,6 @@ class Directory(object):
                        this Directory object lives. This keeps the
                        parent object alive.
         """
-        assert isinstance(path, unicode), "Path needs to be an UNICODE object"
         self._path = path
         self._dir_p = dir_p
         self._parent = parent