"""
from ctypes import c_char_p
from notmuch.globals import (nmlib, STATUS, NotmuchError,
- NotmuchFilenamesP, NotmuchMessageP)
+ NotmuchFilenamesP, NotmuchMessageP, _str, Python3StringMixIn)
-class Filenames(object):
+class Filenames(Python3StringMixIn):
"""Represents a list of filenames as returned by notmuch
This object contains the Filenames iterator. The main function is
self._files = None
- def __str__(self):
- return unicode(self).encode('utf-8')
-
def __unicode__(self):
"""Represent Filenames() as newline-separated list of full paths
Copyright 2010 Sebastian Spaeth <Sebastian@SSpaeth.de>'
"""
-
+import sys
from ctypes import CDLL, c_char_p, c_int, Structure, POINTER
#-----------------------------------------------------------------------------
raise ImportError("Could not find shared 'notmuch' library.")
+if sys.version_info[0] == 2:
+ class Python3StringMixIn(object):
+ def __str__(self):
+ return unicode(self).encode('utf-8')
+else:
+ class Python3StringMixIn(object):
+ def __str__(self):
+ return self.__unicode__()
+
+
class Enum(object):
"""Provides ENUMS as "code=Enum(['a','b','c'])" where code.a=0 etc..."""
def __init__(self, names):
STATUS.__name__ = 'STATUS'
-class NotmuchError(Exception):
+class NotmuchError(Exception, Python3StringMixIn):
"""Is initiated with a (notmuch.STATUS[, message=None]). It will not
return an instance of the class NotmuchError, but a derived instance
of a more specific Error Message, e.g. OutOfMemoryError. Each status
self.status = status
self.message = message
- def __str__(self):
- return unicode(self).encode('utf-8')
-
def __unicode__(self):
if self.message is not None:
return self.message
from ctypes import c_char_p, c_long, c_uint, c_int
from datetime import date
-from notmuch.globals import (nmlib, STATUS, NotmuchError, Enum, _str,
+from notmuch.globals import (
+ nmlib, STATUS, NotmuchError, Enum, _str, Python3StringMixIn,
NotmuchTagsP, NotmuchMessagesP, NotmuchMessageP, NotmuchFilenamesP)
from notmuch.tag import Tags
from notmuch.filename import Filenames
sys.stdout.write(set_end)
-class Message(object):
+class Message(Python3StringMixIn):
"""Represents a single Email message
Technically, this wraps the underlying *notmuch_message_t*
"""Represent a Message() object by str()"""
return self.__str__()
- def __str__(self):
- return unicode(self).encode('utf-8')
-
def __unicode__(self):
format = "%s (%s) (%s)"
return format % (self.get_header('from'),
Copyright 2010 Sebastian Spaeth <Sebastian@SSpaeth.de>'
"""
from ctypes import c_char_p
-from notmuch.globals import nmlib, STATUS, NotmuchError, NotmuchTagsP
+from notmuch.globals import nmlib, STATUS, NotmuchError, NotmuchTagsP, _str, Python3StringMixIn
-class Tags(object):
+class Tags(Python3StringMixIn):
"""Represents a list of notmuch tags
This object provides an iterator over a list of notmuch tags (which
left."""
return self._valid(self._tags) > 0
- def __str__(self):
- return unicode(self).encode('utf-8')
-
def __unicode__(self):
"""string representation of :class:`Tags`: a space separated list of tags
from ctypes import c_char_p, c_long, c_int
from notmuch.globals import (nmlib, STATUS,
NotmuchError, NotmuchThreadP, NotmuchThreadsP, NotmuchMessagesP,
- NotmuchTagsP,)
+ NotmuchTagsP, Python3StringMixIn)
from notmuch.message import Messages
from notmuch.tag import Tags
from datetime import date
-class Threads(object):
+class Threads(Python3StringMixIn):
"""Represents a list of notmuch threads
This object provides an iterator over a list of notmuch threads
raise NotmuchError(STATUS.NULL_POINTER)
return Tags(tags_p, self)
- def __str__(self):
- return unicode(self).encode('utf-8')
-
def __unicode__(self):
frm = "thread:%s %12s [%d/%d] %s; %s (%s)"