MCPcopy Index your code
hub / github.com/RustPython/RustPython / MaildirMessage

Class MaildirMessage

Lib/mailbox.py:1601–1707  ·  view source on GitHub ↗

Message with Maildir-specific properties.

Source from the content-addressed store, hash-verified

1599
1600
1601class MaildirMessage(Message):
1602 """Message with Maildir-specific properties."""
1603
1604 _type_specific_attributes = ['_subdir', '_info', '_date']
1605
1606 def __init__(self, message=None):
1607 """Initialize a MaildirMessage instance."""
1608 self._subdir = 'new'
1609 self._info = ''
1610 self._date = time.time()
1611 Message.__init__(self, message)
1612
1613 def get_subdir(self):
1614 """Return 'new' or 'cur'."""
1615 return self._subdir
1616
1617 def set_subdir(self, subdir):
1618 """Set subdir to 'new' or 'cur'."""
1619 if subdir == 'new' or subdir == 'cur':
1620 self._subdir = subdir
1621 else:
1622 raise ValueError("subdir must be 'new' or 'cur': %s" % subdir)
1623
1624 def get_flags(self):
1625 """Return as a string the flags that are set."""
1626 if self._info.startswith('2,'):
1627 return self._info[2:]
1628 else:
1629 return ''
1630
1631 def set_flags(self, flags):
1632 """Set the given flags and unset all others."""
1633 self._info = '2,' + ''.join(sorted(flags))
1634
1635 def add_flag(self, flag):
1636 """Set the given flag(s) without changing others."""
1637 self.set_flags(''.join(set(self.get_flags()) | set(flag)))
1638
1639 def remove_flag(self, flag):
1640 """Unset the given string flag(s) without changing others."""
1641 if self.get_flags():
1642 self.set_flags(''.join(set(self.get_flags()) - set(flag)))
1643
1644 def get_date(self):
1645 """Return delivery date of message, in seconds since the epoch."""
1646 return self._date
1647
1648 def set_date(self, date):
1649 """Set delivery date of message, in seconds since the epoch."""
1650 try:
1651 self._date = float(date)
1652 except ValueError:
1653 raise TypeError("can't convert to float: %s" % date) from None
1654
1655 def get_info(self):
1656 """Get the message's "info" as a string."""
1657 return self._info
1658

Callers 1

get_messageMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected