Changeset 168
- Timestamp:
- 07/25/08 22:53:23 (6 months ago)
- Files:
-
- src/jmc/model/account.py (modified) (3 diffs)
- src/jmc/model/tests/account.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
src/jmc/model/account.py
r167 r168 436 436 return current_folder.keys() 437 437 438 def populate_handler(self ):438 def populate_handler(self, try_other_delimiter=True, testing_delimiter="/"): 439 439 """ 440 440 Handler called when populating account … … 446 446 if typ == 'OK': 447 447 line = data[0] 448 match = self._regexp_list.match(line) 449 if match is not None: 450 self.delimiter = match.group(2) 448 if line is None: 449 if try_other_delimiter: 450 self.mailbox = self.mailbox.replace(testing_delimiter, 451 ".") 452 self.populate_handler(False, ".") 453 return 454 else: 455 self.disconnect() 456 raise Exception("Cannot find mailbox " + self.mailbox) 451 457 else: 452 self.disconnect() 453 raise Exception("Cannot find delimiter for mailbox " 454 + self.mailbox) 458 match = self._regexp_list.match(line) 459 if match is not None: 460 self.delimiter = match.group(2) 461 else: 462 self.disconnect() 463 raise Exception("Cannot find delimiter for mailbox " 464 + self.mailbox) 455 465 else: 456 466 self.disconnect() … … 458 468 self.disconnect() 459 469 # replace any previous delimiter in self.mailbox by "/" 460 if self.delimiter != "/": 461 self.mailbox = self.mailbox.replace(self.delimiter, "/") 470 if self.delimiter != testing_delimiter: 471 self.mailbox = self.mailbox.replace(testing_delimiter, 472 self.delimiter) 462 473 463 474 src/jmc/model/tests/account.py
r154 r168 731 731 def test_populate_handler(self): 732 732 self.assertEquals(".", self.imap_account.delimiter) 733 self.imap_account.mailbox = "INBOX .dir1.subdir2"733 self.imap_account.mailbox = "INBOX/dir1/subdir2" 734 734 def call_func(self): 735 735 self.imap_account.populate_handler() 736 self.assertEquals("INBOX /dir1/subdir2", self.imap_account.mailbox)736 self.assertEquals("INBOX.dir1.subdir2", self.imap_account.mailbox) 737 737 test_func = self.make_test(\ 738 738 [lambda data: '* LIST () "." "INBOX.dir1.subdir2"\r\n' + \ 739 739 data.split()[0] + ' OK LIST completed\r\n'], 740 740 ["^[^ ]* LIST \"?INBOX.dir1.subdir2\"? \*"], 741 call_func) 742 test_func() 743 744 def test_populate_handler_wrong_default_delimiter(self): 745 self.imap_account.delimiter = "/" 746 self.imap_account.mailbox = "INBOX/dir1/subdir2" 747 def call_func(self): 748 self.imap_account.populate_handler() 749 self.assertEquals("INBOX.dir1.subdir2", self.imap_account.mailbox) 750 self.assertEquals(".", self.imap_account.delimiter) 751 test_func = self.make_test(\ 752 [lambda data: data.split()[0] + ' OK LIST completed\r\n', 753 lambda data: '* LIST () "." "INBOX.dir1.subdir2"\r\n' + \ 754 data.split()[0] + ' OK LIST completed\r\n'], 755 ["^[^ ]* LIST \"?INBOX/dir1/subdir2\"? \*", 756 "^[^ ]* LIST \"?INBOX.dir1.subdir2\"? \*"], 741 757 call_func) 742 758 test_func()
