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

Class BabylMessage

Lib/mailbox.py:1906–1998  ·  view source on GitHub ↗

Message with Babyl-specific properties.

Source from the content-addressed store, hash-verified

1904
1905
1906class BabylMessage(Message):
1907 """Message with Babyl-specific properties."""
1908
1909 _type_specific_attributes = ['_labels', '_visible']
1910
1911 def __init__(self, message=None):
1912 """Initialize a BabylMessage instance."""
1913 self._labels = []
1914 self._visible = Message()
1915 Message.__init__(self, message)
1916
1917 def get_labels(self):
1918 """Return a list of labels on the message."""
1919 return self._labels[:]
1920
1921 def set_labels(self, labels):
1922 """Set the list of labels on the message."""
1923 self._labels = list(labels)
1924
1925 def add_label(self, label):
1926 """Add label to list of labels on the message."""
1927 if isinstance(label, str):
1928 if label not in self._labels:
1929 self._labels.append(label)
1930 else:
1931 raise TypeError('label must be a string: %s' % type(label))
1932
1933 def remove_label(self, label):
1934 """Remove label from the list of labels on the message."""
1935 try:
1936 self._labels.remove(label)
1937 except ValueError:
1938 pass
1939
1940 def get_visible(self):
1941 """Return a Message representation of visible headers."""
1942 return Message(self._visible)
1943
1944 def set_visible(self, visible):
1945 """Set the Message representation of visible headers."""
1946 self._visible = Message(visible)
1947
1948 def update_visible(self):
1949 """Update and/or sensibly generate a set of visible headers."""
1950 for header in self._visible.keys():
1951 if header in self:
1952 self._visible.replace_header(header, self[header])
1953 else:
1954 del self._visible[header]
1955 for header in ('Date', 'From', 'Reply-To', 'To', 'CC', 'Subject'):
1956 if header in self and header not in self._visible:
1957 self._visible[header] = self[header]
1958
1959 def _explain_to(self, message):
1960 """Copy Babyl-specific state to message insofar as possible."""
1961 if isinstance(message, MaildirMessage):
1962 labels = set(self.get_labels())
1963 if 'unseen' in labels:

Callers 1

get_messageMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…