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

Method _handle_message

Lib/email/generator.py:359–377  ·  view source on GitHub ↗
(self, msg)

Source from the content-addressed store, hash-verified

357 self._fp.write(self._encoded_NL.join(blocks))
358
359 def _handle_message(self, msg):
360 s = self._new_buffer()
361 g = self.clone(s)
362 # The payload of a message/rfc822 part should be a multipart sequence
363 # of length 1. The zeroth element of the list should be the Message
364 # object for the subpart. Extract that object, stringify it, and
365 # write it out.
366 # Except, it turns out, when it's a string instead, which happens when
367 # and only when HeaderParser is used on a message of mime type
368 # message/rfc822. Such messages are generated by, for example,
369 # Groupwise when forwarding unadorned messages. (Issue 7970.) So
370 # in that case we just emit the string body.
371 payload = msg._payload
372 if isinstance(payload, list):
373 g.flatten(msg.get_payload(0), unixfrom=False, linesep=self._NL)
374 payload = s.getvalue()
375 else:
376 payload = self._encode(payload)
377 self._fp.write(payload)
378
379 # This used to be a module level function; we use a classmethod for this
380 # and _compile_re so we can continue to provide the module level function

Callers

nothing calls this directly

Calls 7

_new_bufferMethod · 0.95
cloneMethod · 0.95
_encodeMethod · 0.95
get_payloadMethod · 0.80
flattenMethod · 0.45
getvalueMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected