python: Update Python bindings for new notmuch_database_{open, create} signatures

This commit is contained in:
Austin Clements 2012-04-30 12:25:36 -04:00 committed by David Bremner
parent 2e346b9e2a
commit 0a357fe410

View file

@ -88,8 +88,8 @@ class Database(object):
"""notmuch_database_open""" """notmuch_database_open"""
_open = nmlib.notmuch_database_open _open = nmlib.notmuch_database_open
_open.argtypes = [c_char_p, c_uint] _open.argtypes = [c_char_p, c_uint, POINTER(NotmuchDatabaseP)]
_open.restype = NotmuchDatabaseP _open.restype = c_uint
"""notmuch_database_upgrade""" """notmuch_database_upgrade"""
_upgrade = nmlib.notmuch_database_upgrade _upgrade = nmlib.notmuch_database_upgrade
@ -115,8 +115,8 @@ class Database(object):
"""notmuch_database_create""" """notmuch_database_create"""
_create = nmlib.notmuch_database_create _create = nmlib.notmuch_database_create
_create.argtypes = [c_char_p] _create.argtypes = [c_char_p, POINTER(NotmuchDatabaseP)]
_create.restype = NotmuchDatabaseP _create.restype = c_uint
def __init__(self, path = None, create = False, def __init__(self, path = None, create = False,
mode = MODE.READ_ONLY): mode = MODE.READ_ONLY):
@ -186,12 +186,13 @@ class Database(object):
raise NotmuchError(message="Cannot create db, this Database() " raise NotmuchError(message="Cannot create db, this Database() "
"already has an open one.") "already has an open one.")
res = Database._create(_str(path), Database.MODE.READ_WRITE) db = NotmuchDatabaseP()
status = Database._create(_str(path), Database.MODE.READ_WRITE, byref(db))
if not res: if status != STATUS.SUCCESS:
raise NotmuchError( raise NotmuchError(status)
message="Could not create the specified database") self._db = db
self._db = res return status
def open(self, path, mode=0): def open(self, path, mode=0):
"""Opens an existing database """Opens an existing database
@ -205,11 +206,13 @@ class Database(object):
:raises: Raises :exc:`NotmuchError` in case of any failure :raises: Raises :exc:`NotmuchError` in case of any failure
(possibly after printing an error message on stderr). (possibly after printing an error message on stderr).
""" """
res = Database._open(_str(path), mode) db = NotmuchDatabaseP()
status = Database._open(_str(path), mode, byref(db))
if not res: if status != STATUS.SUCCESS:
raise NotmuchError(message="Could not open the specified database") raise NotmuchError(status)
self._db = res self._db = db
return status
_close = nmlib.notmuch_database_close _close = nmlib.notmuch_database_close
_close.argtypes = [NotmuchDatabaseP] _close.argtypes = [NotmuchDatabaseP]