X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=bindings%2Fpython%2Fnotmuch%2Fdatabase.py;h=3f6e04d6f4d0e8e25dc5e1427a580712649a73e1;hb=26d52cf6cf4573fa2ef41b6150f5686bc91ea785;hp=471adaa53e1ac3e787ccfcc36d9ea0e5c53e1daf;hpb=86b0aeb1ca0f12286e13b71d7f025ba8a59a808d;p=obsolete%2Fnotmuch-old diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py index 471adaa5..3f6e04d6 100644 --- a/bindings/python/notmuch/database.py +++ b/bindings/python/notmuch/database.py @@ -385,7 +385,7 @@ class Database(object): be added. """ self._assert_db_is_initialized() - msg_p = c_void_p() + msg_p = NotmuchMessageP() status = self._add_message(self._db, _str(filename), byref(msg_p)) if not status in [STATUS.SUCCESS, STATUS.DUPLICATE_MESSAGE_ID]: @@ -453,7 +453,7 @@ class Database(object): the database was not intitialized. """ self._assert_db_is_initialized() - msg_p = c_void_p() + msg_p = NotmuchMessageP() status = Database._find_message(self._db, _str(msgid), byref(msg_p)) if status != STATUS.SUCCESS: raise NotmuchError(status) @@ -487,7 +487,7 @@ class Database(object): *Added in notmuch 0.9*""" self._assert_db_is_initialized() - msg_p = c_void_p() + msg_p = NotmuchMessageP() status = Database._find_message_by_filename(self._db, _str(filename), byref(msg_p)) if status != STATUS.SUCCESS: @@ -543,7 +543,13 @@ class Database(object): """ Reads a user's notmuch config and returns his db location Throws a NotmuchError if it cannot find it""" - from ConfigParser import SafeConfigParser + try: + # python3.x + from configparser import SafeConfigParser + except ImportError: + # python2.x + from ConfigParser import SafeConfigParser + config = SafeConfigParser() conf_f = os.getenv('NOTMUCH_CONFIG', os.path.expanduser('~/.notmuch-config')) @@ -919,7 +925,7 @@ class Filenames(object): _move_to_next.argtypes = [NotmuchFilenamesP] _move_to_next.restype = None - def next(self): + def __next__(self): if self._files_p is None: raise NotmuchError(STATUS.NOT_INITIALIZED) @@ -930,6 +936,7 @@ class Filenames(object): file = Filenames._get(self._files_p) self._move_to_next(self._files_p) return file + next = __next__ # python2.x iterator protocol compatibility def __len__(self): """len(:class:`Filenames`) returns the number of contained files