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

Class Message

Lib/mailbox.py:1571–1605  ·  view source on GitHub ↗

Message with mailbox-format-specific properties.

Source from the content-addressed store, hash-verified

1569
1570
1571class Message(email.message.Message):
1572 """Message with mailbox-format-specific properties."""
1573
1574 def __init__(self, message=None):
1575 """Initialize a Message instance."""
1576 if isinstance(message, email.message.Message):
1577 self._become_message(copy.deepcopy(message))
1578 if isinstance(message, Message):
1579 message._explain_to(self)
1580 elif isinstance(message, bytes):
1581 self._become_message(email.message_from_bytes(message))
1582 elif isinstance(message, str):
1583 self._become_message(email.message_from_string(message))
1584 elif isinstance(message, io.TextIOWrapper):
1585 self._become_message(email.message_from_file(message))
1586 elif hasattr(message, "read"):
1587 self._become_message(email.message_from_binary_file(message))
1588 elif message is None:
1589 email.message.Message.__init__(self)
1590 else:
1591 raise TypeError('Invalid message type: %s' % type(message))
1592
1593 def _become_message(self, message):
1594 """Assume the non-format-specific state of message."""
1595 type_specific = getattr(message, '_type_specific_attributes', [])
1596 for name in message.__dict__:
1597 if name not in type_specific:
1598 self.__dict__[name] = message.__dict__[name]
1599
1600 def _explain_to(self, message):
1601 """Copy format-specific state to message insofar as possible."""
1602 if isinstance(message, Message):
1603 return # There's nothing format-specific to explain.
1604 else:
1605 raise TypeError('Cannot convert to specified type')
1606
1607
1608class MaildirMessage(Message):

Callers 3

__init__Method · 0.70
get_visibleMethod · 0.70
set_visibleMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…