Select a mailbox. Flush all untagged responses. (typ, [data]) = .select(mailbox='INBOX', readonly=False) 'data' is count of messages in mailbox ('EXISTS' response). Mandated responses are ('FLAGS', 'EXISTS', 'RECENT', 'UIDVALIDITY'), so
(self, mailbox='INBOX', readonly=False)
| 736 | |
| 737 | |
| 738 | def select(self, mailbox='INBOX', readonly=False): |
| 739 | """Select a mailbox. |
| 740 | |
| 741 | Flush all untagged responses. |
| 742 | |
| 743 | (typ, [data]) = <instance>.select(mailbox='INBOX', readonly=False) |
| 744 | |
| 745 | 'data' is count of messages in mailbox ('EXISTS' response). |
| 746 | |
| 747 | Mandated responses are ('FLAGS', 'EXISTS', 'RECENT', 'UIDVALIDITY'), so |
| 748 | other responses should be obtained via <instance>.response('FLAGS') etc. |
| 749 | """ |
| 750 | self.untagged_responses = {} # Flush old responses. |
| 751 | self.is_readonly = readonly |
| 752 | if readonly: |
| 753 | name = 'EXAMINE' |
| 754 | else: |
| 755 | name = 'SELECT' |
| 756 | typ, dat = self._simple_command(name, mailbox) |
| 757 | if typ != 'OK': |
| 758 | self.state = 'AUTH' # Might have been 'SELECTED' |
| 759 | return typ, dat |
| 760 | self.state = 'SELECTED' |
| 761 | if 'READ-ONLY' in self.untagged_responses \ |
| 762 | and not readonly: |
| 763 | if __debug__: |
| 764 | if self.debug >= 1: |
| 765 | self._dump_ur(self.untagged_responses) |
| 766 | raise self.readonly('%s is not writable' % mailbox) |
| 767 | return typ, self.untagged_responses.get('EXISTS', [None]) |
| 768 | |
| 769 | |
| 770 | def setacl(self, mailbox, who, what): |
no test coverage detected