]> git.notmuchmail.org Git - notmuch/blobdiff - bindings/python/notmuch/message.py
fix typos
[notmuch] / bindings / python / notmuch / message.py
index 0cac09c1c133cee415cc62125b8262f6c0182e25..1b1f2174f4fcbeb2c6925becd41cabbceeba9b56 100644 (file)
@@ -12,7 +12,7 @@ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 for more details.
 
 You should have received a copy of the GNU General Public License
-along with notmuch.  If not, see <http://www.gnu.org/licenses/>.
+along with notmuch.  If not, see <https://www.gnu.org/licenses/>.
 
 Copyright 2010 Sebastian Spaeth <Sebastian@SSpaeth.de>
                Jesse Rosenthal <jrosenthal@jhu.edu>
@@ -41,10 +41,7 @@ from .tag import Tags
 from .filenames import Filenames
 
 import email
-try:
-    import simplejson as json
-except ImportError:
-    import json
+import sys
 
 
 class Message(Python3StringMixIn):
@@ -226,7 +223,7 @@ class Message(Python3StringMixIn):
         :returns: The header value as string
         :raises: :exc:`NotInitializedError` if the message is not
                  initialized
-        :raises: :exc:`NullPointerError` if any error occured
+        :raises: :exc:`NullPointerError` if any error occurred
         """
         if not self._msg:
             raise NotInitializedError()
@@ -298,13 +295,13 @@ class Message(Python3StringMixIn):
         :returns: A :class:`Tags` iterator.
         :raises: :exc:`NotInitializedError` if the message is not
                  initialized
-        :raises: :exc:`NullPointerError` if any error occured
+        :raises: :exc:`NullPointerError` if any error occurred
         """
         if not self._msg:
             raise NotInitializedError()
 
         tags_p = Message._get_tags(self._msg)
-        if tags_p == None:
+        if not tags_p:
             raise NullPointerError()
         return Tags(tags_p, self)
 
@@ -570,13 +567,13 @@ class Message(Python3StringMixIn):
         logical OR operator.)
 
         As a convenience, you can set the sync_maildir_flags parameter in
-        :meth:`Database.add_message` to implicitly call this.
+        :meth:`Database.index_file` to implicitly call this.
 
         :returns: a :class:`STATUS`. In short, you want to see
             notmuch.STATUS.SUCCESS here. See there for details."""
         if not self._msg:
             raise NotInitializedError()
-        return Message._tags_to_maildir_flags(self._msg)
+        return Message._maildir_flags_to_tags(self._msg)
 
     def __repr__(self):
         """Represent a Message() object by str()"""
@@ -591,8 +588,11 @@ class Message(Python3StringMixIn):
 
     def get_message_parts(self):
         """Output like notmuch show"""
-        fp = open(self.get_filename())
-        email_msg = email.message_from_file(fp)
+        fp = open(self.get_filename(), 'rb')
+        if sys.version_info[0] < 3:
+            email_msg = email.message_from_file(fp)
+        else:
+            email_msg = email.message_from_binary_file(fp)
         fp.close()
 
         out = []