MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / MaildirMessage

Class MaildirMessage

tools/python-3.11.9-amd64/Lib/mailbox.py:1527–1633  ·  view source on GitHub ↗

Message with Maildir-specific properties.

Source from the content-addressed store, hash-verified

1525
1526
1527class MaildirMessage(Message):
1528 """Message with Maildir-specific properties."""
1529
1530 _type_specific_attributes = ['_subdir', '_info', '_date']
1531
1532 def __init__(self, message=None):
1533 """Initialize a MaildirMessage instance."""
1534 self._subdir = 'new'
1535 self._info = ''
1536 self._date = time.time()
1537 Message.__init__(self, message)
1538
1539 def get_subdir(self):
1540 """Return 'new' or 'cur'."""
1541 return self._subdir
1542
1543 def set_subdir(self, subdir):
1544 """Set subdir to 'new' or 'cur'."""
1545 if subdir == 'new' or subdir == 'cur':
1546 self._subdir = subdir
1547 else:
1548 raise ValueError("subdir must be 'new' or 'cur': %s" % subdir)
1549
1550 def get_flags(self):
1551 """Return as a string the flags that are set."""
1552 if self._info.startswith('2,'):
1553 return self._info[2:]
1554 else:
1555 return ''
1556
1557 def set_flags(self, flags):
1558 """Set the given flags and unset all others."""
1559 self._info = '2,' + ''.join(sorted(flags))
1560
1561 def add_flag(self, flag):
1562 """Set the given flag(s) without changing others."""
1563 self.set_flags(''.join(set(self.get_flags()) | set(flag)))
1564
1565 def remove_flag(self, flag):
1566 """Unset the given string flag(s) without changing others."""
1567 if self.get_flags():
1568 self.set_flags(''.join(set(self.get_flags()) - set(flag)))
1569
1570 def get_date(self):
1571 """Return delivery date of message, in seconds since the epoch."""
1572 return self._date
1573
1574 def set_date(self, date):
1575 """Set delivery date of message, in seconds since the epoch."""
1576 try:
1577 self._date = float(date)
1578 except ValueError:
1579 raise TypeError("can't convert to float: %s" % date) from None
1580
1581 def get_info(self):
1582 """Get the message's "info" as a string."""
1583 return self._info
1584

Callers 1

get_messageMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected