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 other res
(self, mailbox='INBOX', readonly=False)
| 838 | |
| 839 | |
| 840 | def select(self, mailbox='INBOX', readonly=False): |
| 841 | """Select a mailbox. |
| 842 | |
| 843 | Flush all untagged responses. |
| 844 | |
| 845 | (typ, [data]) = <instance>.select(mailbox='INBOX', readonly=False) |
| 846 | |
| 847 | 'data' is count of messages in mailbox ('EXISTS' response). |
| 848 | |
| 849 | Mandated responses are ('FLAGS', 'EXISTS', 'RECENT', 'UIDVALIDITY'), so |
| 850 | other responses should be obtained via <instance>.response('FLAGS') etc. |
| 851 | """ |
| 852 | self.untagged_responses = {} # Flush old responses. |
| 853 | self.is_readonly = readonly |
| 854 | if readonly: |
| 855 | name = 'EXAMINE' |
| 856 | else: |
| 857 | name = 'SELECT' |
| 858 | typ, dat = self._simple_command(name, mailbox) |
| 859 | if typ != 'OK': |
| 860 | self.state = 'AUTH' # Might have been 'SELECTED' |
| 861 | return typ, dat |
| 862 | self.state = 'SELECTED' |
| 863 | if 'READ-ONLY' in self.untagged_responses \ |
| 864 | and not readonly: |
| 865 | if __debug__: |
| 866 | if self.debug >= 1: |
| 867 | self._dump_ur(self.untagged_responses) |
| 868 | raise self.readonly('%s is not writable' % mailbox) |
| 869 | return typ, self.untagged_responses.get('EXISTS', [None]) |
| 870 | |
| 871 | |
| 872 | def setacl(self, mailbox, who, what): |
no test coverage detected