MCPcopy Index your code
hub / github.com/python/cpython / get_body

Method get_body

Lib/email/message.py:1050–1068  ·  view source on GitHub ↗

Return best candidate mime part for display as 'body' of message. Do a depth first search, starting with self, looking for the first part matching each of the items in preferencelist, and return the part corresponding to the first item that has a match, or None if no items

(self, preferencelist=('related', 'html', 'plain'))

Source from the content-addressed store, hash-verified

1048 yield from self._find_body(candidate, preferencelist)
1049
1050 def get_body(self, preferencelist=('related', 'html', 'plain')):
1051 """Return best candidate mime part for display as 'body' of message.
1052
1053 Do a depth first search, starting with self, looking for the first part
1054 matching each of the items in preferencelist, and return the part
1055 corresponding to the first item that has a match, or None if no items
1056 have a match. If 'related' is not included in preferencelist, consider
1057 the root part of any multipart/related encountered as a candidate
1058 match. Ignore parts with 'Content-Disposition: attachment'.
1059 """
1060 best_prio = len(preferencelist)
1061 body = None
1062 for prio, part in self._find_body(self, preferencelist):
1063 if prio < best_prio:
1064 best_prio = prio
1065 body = part
1066 if prio == 0:
1067 break
1068 return body
1069
1070 _body_types = {('text', 'plain'),
1071 ('text', 'html'),

Calls 1

_find_bodyMethod · 0.95

Tested by 3

message_as_get_bodyMethod · 0.64