mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-12-25 19:04:53 +01:00
python: remove functions that have been marked as deprecated in 0.13
Removes Message.format_message_{internal,as_json,as_text}. This code adds functionality at the python level that is unlikely to be useful for anyone. Furthermore the python bindings strive to be a thin wrapper around libnotmuch. The code has been marked as deprecated in 0.13 and is now removed. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
This commit is contained in:
parent
eab15cc707
commit
cd8fe01013
1 changed files with 0 additions and 129 deletions
|
@ -610,135 +610,6 @@ class Message(Python3StringMixIn):
|
|||
out_part = parts[(num - 1)]
|
||||
return out_part.get_payload(decode=True)
|
||||
|
||||
def format_message_internal(self):
|
||||
"""Create an internal representation of the message parts,
|
||||
which can easily be output to json, text, or another output
|
||||
format. The argument match tells whether this matched a
|
||||
query.
|
||||
|
||||
.. deprecated:: 0.13
|
||||
This code adds functionality at the python
|
||||
level that is unlikely to be useful for
|
||||
anyone. Furthermore the python bindings strive
|
||||
to be a thin wrapper around libnotmuch, so
|
||||
this code will be removed in notmuch 0.14.
|
||||
"""
|
||||
output = {}
|
||||
output["id"] = self.get_message_id()
|
||||
output["match"] = self.is_match()
|
||||
output["filename"] = self.get_filename()
|
||||
output["tags"] = list(self.get_tags())
|
||||
|
||||
headers = {}
|
||||
for h in ["Subject", "From", "To", "Cc", "Bcc", "Date"]:
|
||||
headers[h] = self.get_header(h)
|
||||
output["headers"] = headers
|
||||
|
||||
body = []
|
||||
parts = self.get_message_parts()
|
||||
for i in xrange(len(parts)):
|
||||
msg = parts[i]
|
||||
part_dict = {}
|
||||
part_dict["id"] = i + 1
|
||||
# We'll be using this is a lot, so let's just get it once.
|
||||
cont_type = msg.get_content_type()
|
||||
part_dict["content-type"] = cont_type
|
||||
# NOTE:
|
||||
# Now we emulate the current behaviour, where it ignores
|
||||
# the html if there's a text representation.
|
||||
#
|
||||
# This is being worked on, but it will be easier to fix
|
||||
# here in the future than to end up with another
|
||||
# incompatible solution.
|
||||
disposition = msg["Content-Disposition"]
|
||||
if disposition and disposition.lower().startswith("attachment"):
|
||||
part_dict["filename"] = msg.get_filename()
|
||||
else:
|
||||
if cont_type.lower() == "text/plain":
|
||||
part_dict["content"] = msg.get_payload()
|
||||
elif (cont_type.lower() == "text/html" and
|
||||
i == 0):
|
||||
part_dict["content"] = msg.get_payload()
|
||||
body.append(part_dict)
|
||||
|
||||
output["body"] = body
|
||||
|
||||
return output
|
||||
|
||||
def format_message_as_json(self, indent=0):
|
||||
"""Outputs the message as json. This is essentially the same
|
||||
as python's dict format, but we run it through, just so we
|
||||
don't have to worry about the details.
|
||||
|
||||
.. deprecated:: 0.13
|
||||
This code adds functionality at the python
|
||||
level that is unlikely to be useful for
|
||||
anyone. Furthermore the python bindings strive
|
||||
to be a thin wrapper around libnotmuch, so
|
||||
this code will be removed in notmuch 0.14.
|
||||
"""
|
||||
return json.dumps(self.format_message_internal())
|
||||
|
||||
def format_message_as_text(self, indent=0):
|
||||
"""Outputs it in the old-fashioned notmuch text form. Will be
|
||||
easy to change to a new format when the format changes.
|
||||
|
||||
.. deprecated:: 0.13
|
||||
This code adds functionality at the python
|
||||
level that is unlikely to be useful for
|
||||
anyone. Furthermore the python bindings strive
|
||||
to be a thin wrapper around libnotmuch, so
|
||||
this code will be removed in notmuch 0.14.
|
||||
"""
|
||||
|
||||
|
||||
format = self.format_message_internal()
|
||||
output = "\fmessage{ id:%s depth:%d match:%d filename:%s" \
|
||||
% (format['id'], indent, format['match'], format['filename'])
|
||||
output += "\n\fheader{"
|
||||
|
||||
#Todo: this date is supposed to be prettified, as in the index.
|
||||
output += "\n%s (%s) (" % (format["headers"]["From"],
|
||||
format["headers"]["Date"])
|
||||
output += ", ".join(format["tags"])
|
||||
output += ")"
|
||||
|
||||
output += "\nSubject: %s" % format["headers"]["Subject"]
|
||||
output += "\nFrom: %s" % format["headers"]["From"]
|
||||
output += "\nTo: %s" % format["headers"]["To"]
|
||||
if format["headers"]["Cc"]:
|
||||
output += "\nCc: %s" % format["headers"]["Cc"]
|
||||
if format["headers"]["Bcc"]:
|
||||
output += "\nBcc: %s" % format["headers"]["Bcc"]
|
||||
output += "\nDate: %s" % format["headers"]["Date"]
|
||||
output += "\n\fheader}"
|
||||
|
||||
output += "\n\fbody{"
|
||||
|
||||
parts = format["body"]
|
||||
parts.sort(key=lambda x: x['id'])
|
||||
for p in parts:
|
||||
if not "filename" in p:
|
||||
output += "\n\fpart{ "
|
||||
output += "ID: %d, Content-type: %s\n" % (p["id"],
|
||||
p["content-type"])
|
||||
if "content" in p:
|
||||
output += "\n%s\n" % p["content"]
|
||||
else:
|
||||
output += "Non-text part: %s\n" % p["content-type"]
|
||||
output += "\n\fpart}"
|
||||
else:
|
||||
output += "\n\fattachment{ "
|
||||
output += "ID: %d, Content-type:%s\n" % (p["id"],
|
||||
p["content-type"])
|
||||
output += "Attachment: %s\n" % p["filename"]
|
||||
output += "\n\fattachment}\n"
|
||||
|
||||
output += "\n\fbody}\n"
|
||||
output += "\n\fmessage}"
|
||||
|
||||
return output
|
||||
|
||||
def __hash__(self):
|
||||
"""Implement hash(), so we can use Message() sets"""
|
||||
file = self.get_filename()
|
||||
|
|
Loading…
Reference in a new issue