mirror of
https://git.notmuchmail.org/git/notmuch
synced 2025-02-17 23:53:15 +01:00
python: pep8 compliance for database.py
This commit is contained in:
parent
61f0184707
commit
e69e30edd7
1 changed files with 80 additions and 80 deletions
|
@ -24,6 +24,7 @@ from notmuch.thread import Threads
|
||||||
from notmuch.message import Messages, Message
|
from notmuch.message import Messages, Message
|
||||||
from notmuch.tag import Tags
|
from notmuch.tag import Tags
|
||||||
|
|
||||||
|
|
||||||
class Database(object):
|
class Database(object):
|
||||||
"""Represents a notmuch database (wraps notmuch_database_t)
|
"""Represents a notmuch database (wraps notmuch_database_t)
|
||||||
|
|
||||||
|
@ -100,7 +101,7 @@ class Database(object):
|
||||||
Database._std_db_path = self._get_user_default_db()
|
Database._std_db_path = self._get_user_default_db()
|
||||||
path = Database._std_db_path
|
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:
|
if create == False:
|
||||||
self.open(path, mode)
|
self.open(path, mode)
|
||||||
else:
|
else:
|
||||||
|
@ -128,8 +129,8 @@ class Database(object):
|
||||||
(after printing an error message on stderr).
|
(after printing an error message on stderr).
|
||||||
"""
|
"""
|
||||||
if self._db is not None:
|
if self._db is not None:
|
||||||
raise NotmuchError(
|
raise NotmuchError(message="Cannot create db, this Database() "
|
||||||
message="Cannot create db, this Database() already has an open one.")
|
"already has an open one.")
|
||||||
|
|
||||||
res = Database._create(path, Database.MODE.READ_WRITE)
|
res = Database._create(path, Database.MODE.READ_WRITE)
|
||||||
|
|
||||||
|
@ -250,13 +251,14 @@ class Database(object):
|
||||||
if not path.startswith(self.get_path()):
|
if not path.startswith(self.get_path()):
|
||||||
# but its initial components are not equal to the db path
|
# but its initial components are not equal to the db path
|
||||||
raise NotmuchError(STATUS.FILE_ERROR,
|
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
|
abs_dirpath = path
|
||||||
else:
|
else:
|
||||||
#we got a relative path, make it absolute
|
#we got a relative path, make it absolute
|
||||||
abs_dirpath = os.path.abspath(os.path.join(self.get_path(), path))
|
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 the Directory, init it with the absolute path
|
||||||
return Directory(abs_dirpath, dir_p, self)
|
return Directory(abs_dirpath, dir_p, self)
|
||||||
|
@ -303,7 +305,8 @@ class Database(object):
|
||||||
An error occurred trying to open the file, (such as
|
An error occurred trying to open the file, (such as
|
||||||
permission denied, or file not found, etc.).
|
permission denied, or file not found, etc.).
|
||||||
STATUS.FILE_NOT_EMAIL
|
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
|
STATUS.READ_ONLY_DATABASE
|
||||||
Database was opened in read-only mode so no message can
|
Database was opened in read-only mode so no message can
|
||||||
be added.
|
be added.
|
||||||
|
@ -348,7 +351,8 @@ class Database(object):
|
||||||
database with at least one other filename.
|
database with at least one other filename.
|
||||||
|
|
||||||
:exception: Raises a :exc:`NotmuchError` with the following meaning.
|
: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
|
STATUS.READ_ONLY_DATABASE
|
||||||
Database was opened in read-only mode so no message can be
|
Database was opened in read-only mode so no message can be
|
||||||
|
@ -443,8 +447,8 @@ class Database(object):
|
||||||
os.path.expanduser('~/.notmuch-config'))
|
os.path.expanduser('~/.notmuch-config'))
|
||||||
config.read(conf_f)
|
config.read(conf_f)
|
||||||
if not config.has_option('database', 'path'):
|
if not config.has_option('database', 'path'):
|
||||||
raise NotmuchError(message=
|
raise NotmuchError(message="No DB path specified"
|
||||||
"No DB path specified and no user default found")
|
" and no user default found")
|
||||||
return config.get('database', 'path')
|
return config.get('database', 'path')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -456,7 +460,7 @@ class Database(object):
|
||||||
"""
|
"""
|
||||||
return self._db
|
return self._db
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
class Query(object):
|
class Query(object):
|
||||||
"""Represents a search query on an opened :class:`Database`.
|
"""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 = nmlib.notmuch_query_search_messages
|
||||||
_search_messages.restype = c_void_p
|
_search_messages.restype = c_void_p
|
||||||
|
|
||||||
|
|
||||||
"""notmuch_query_count_messages"""
|
"""notmuch_query_count_messages"""
|
||||||
_count_messages = nmlib.notmuch_query_count_messages
|
_count_messages = nmlib.notmuch_query_count_messages
|
||||||
_count_messages.restype = c_uint
|
_count_messages.restype = c_uint
|
||||||
|
@ -633,7 +636,6 @@ class Query(object):
|
||||||
nmlib.notmuch_query_destroy(self._query)
|
nmlib.notmuch_query_destroy(self._query)
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
class Directory(object):
|
class Directory(object):
|
||||||
"""Represents a directory entry in the notmuch directory
|
"""Represents a directory entry in the notmuch directory
|
||||||
|
|
||||||
|
@ -665,7 +667,7 @@ class Directory(object):
|
||||||
_get_child_directories.restype = c_void_p
|
_get_child_directories.restype = c_void_p
|
||||||
|
|
||||||
def _verify_dir_initialized(self):
|
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:
|
if self._dir_p is None:
|
||||||
raise NotmuchError(STATUS.NOT_INITIALIZED)
|
raise NotmuchError(STATUS.NOT_INITIALIZED)
|
||||||
|
|
||||||
|
@ -683,7 +685,6 @@ class Directory(object):
|
||||||
self._dir_p = dir_p
|
self._dir_p = dir_p
|
||||||
self._parent = parent
|
self._parent = parent
|
||||||
|
|
||||||
|
|
||||||
def set_mtime(self, mtime):
|
def set_mtime(self, mtime):
|
||||||
"""Sets the mtime value of this directory in the database
|
"""Sets the mtime value of this directory in the database
|
||||||
|
|
||||||
|
@ -795,10 +796,9 @@ class Directory(object):
|
||||||
if self._dir_p is not None:
|
if self._dir_p is not None:
|
||||||
nmlib.notmuch_directory_destroy(self._dir_p)
|
nmlib.notmuch_directory_destroy(self._dir_p)
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
class Filenames(object):
|
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
|
#notmuch_filenames_get
|
||||||
_get = nmlib.notmuch_filenames_get
|
_get = nmlib.notmuch_filenames_get
|
||||||
|
|
Loading…
Add table
Reference in a new issue