python: pep8 compliance for database.py

This commit is contained in:
pazz 2011-07-12 21:11:29 +01:00 committed by Sebastian Spaeth
parent 61f0184707
commit e69e30edd7

View file

@ -24,6 +24,7 @@ from notmuch.thread import Threads
from notmuch.message import Messages, Message
from notmuch.tag import Tags
class Database(object):
"""Represents a notmuch database (wraps notmuch_database_t)
@ -100,7 +101,7 @@ class Database(object):
Database._std_db_path = self._get_user_default_db()
path = Database._std_db_path
assert isinstance(path, basestring), 'Path needs to be a string or None.'
assert isinstance(path, basestring), 'Path must be a string or None.'
if create == False:
self.open(path, mode)
else:
@ -128,8 +129,8 @@ class Database(object):
(after printing an error message on stderr).
"""
if self._db is not None:
raise NotmuchError(
message="Cannot create db, this Database() already has an open one.")
raise NotmuchError(message="Cannot create db, this Database() "
"already has an open one.")
res = Database._create(path, Database.MODE.READ_WRITE)
@ -250,13 +251,14 @@ class Database(object):
if not path.startswith(self.get_path()):
# but its initial components are not equal to the db path
raise NotmuchError(STATUS.FILE_ERROR,
message="Database().get_directory() called with a wrong absolute path.")
message="Database().get_directory() called "
"with a wrong absolute path.")
abs_dirpath = path
else:
#we got a relative path, make it absolute
abs_dirpath = os.path.abspath(os.path.join(self.get_path(), path))
dir_p = Database._get_directory(self._db, path);
dir_p = Database._get_directory(self._db, path)
# return the Directory, init it with the absolute path
return Directory(abs_dirpath, dir_p, self)
@ -303,7 +305,8 @@ class Database(object):
An error occurred trying to open the file, (such as
permission denied, or file not found, etc.).
STATUS.FILE_NOT_EMAIL
The contents of filename don't look like an email message.
The contents of filename don't look like an email
message.
STATUS.READ_ONLY_DATABASE
Database was opened in read-only mode so no message can
be added.
@ -348,7 +351,8 @@ class Database(object):
database with at least one other filename.
:exception: Raises a :exc:`NotmuchError` with the following meaning.
If such an exception occurs, nothing was removed from the database.
If such an exception occurs, nothing was removed from the
database.
STATUS.READ_ONLY_DATABASE
Database was opened in read-only mode so no message can be
@ -443,8 +447,8 @@ class Database(object):
os.path.expanduser('~/.notmuch-config'))
config.read(conf_f)
if not config.has_option('database', 'path'):
raise NotmuchError(message=
"No DB path specified and no user default found")
raise NotmuchError(message="No DB path specified"
" and no user default found")
return config.get('database', 'path')
@property
@ -456,7 +460,7 @@ class Database(object):
"""
return self._db
#------------------------------------------------------------------------------
class Query(object):
"""Represents a search query on an opened :class:`Database`.
@ -491,7 +495,6 @@ class Query(object):
_search_messages = nmlib.notmuch_query_search_messages
_search_messages.restype = c_void_p
"""notmuch_query_count_messages"""
_count_messages = nmlib.notmuch_query_count_messages
_count_messages.restype = c_uint
@ -633,7 +636,6 @@ class Query(object):
nmlib.notmuch_query_destroy(self._query)
#------------------------------------------------------------------------------
class Directory(object):
"""Represents a directory entry in the notmuch directory
@ -665,7 +667,7 @@ class Directory(object):
_get_child_directories.restype = c_void_p
def _verify_dir_initialized(self):
"""Raises a NotmuchError(STATUS.NOT_INITIALIZED) if the dir_p is None"""
"""Raises a NotmuchError(STATUS.NOT_INITIALIZED) if dir_p is None"""
if self._dir_p is None:
raise NotmuchError(STATUS.NOT_INITIALIZED)
@ -683,7 +685,6 @@ class Directory(object):
self._dir_p = dir_p
self._parent = parent
def set_mtime(self, mtime):
"""Sets the mtime value of this directory in the database
@ -795,10 +796,9 @@ class Directory(object):
if self._dir_p is not None:
nmlib.notmuch_directory_destroy(self._dir_p)
#------------------------------------------------------------------------------
class Filenames(object):
"""An iterator over File- or Directory names that are stored in the database
"""
"""An iterator over File- or Directory names stored in the database"""
#notmuch_filenames_get
_get = nmlib.notmuch_filenames_get