Python mailbox.Maildir() Examples
The following are 30
code examples of mailbox.Maildir().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
mailbox
, or try the search function
.
Example #1
Source File: test_mailbox.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_lock_unlock(self): # Lock and unlock the mailbox. For Maildir, this does nothing. self._box.lock() self._box.unlock()
Example #2
Source File: test_mailbox.py From BinderFilter with MIT License | 6 votes |
def test_folder_file_perms(self): # From bug #3228, we want to verify that the file created inside a Maildir # subfolder isn't marked as executable. if not hasattr(os, "stat") or not hasattr(os, "umask"): return orig_umask = os.umask(0) try: subfolder = self._box.add_folder('subfolder') finally: os.umask(orig_umask) path = os.path.join(subfolder._path, 'maildirfolder') st = os.stat(path) perms = st.st_mode self.assertFalse((perms & 0111)) # Execute bits should all be off.
Example #3
Source File: test_mailbox.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_lock_unlock(self): # Lock and unlock the mailbox. For Maildir, this does nothing. self._box.lock() self._box.unlock()
Example #4
Source File: maintenance.py From pixelated-user-agent with GNU Affero General Public License v3.0 | 5 votes |
def _load_mails_as_is(mail_paths, store): deferreds = [] for path in mail_paths: if isfile(path): mbox_mails = mbox(path, factory=None) yield add_mail_folder(store, mbox_mails, 'INBOX', deferreds) else: maildir = Maildir(path, factory=None) yield add_mail_folder(store, maildir, 'INBOX', deferreds) for mail_folder_name in maildir.list_folders(): mail_folder = maildir.get_folder(mail_folder_name) yield add_mail_folder(store, mail_folder, mail_folder_name, deferreds) yield defer.gatherResults(deferreds, consumeErrors=True)
Example #5
Source File: test_old_mailbox.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_empty_maildir(self): """Test an empty maildir mailbox""" # Test for regression on bug #117490: self.mbox = mailbox.Maildir(test_support.TESTFN) self.assert_(len(self.mbox) == 0) self.assert_(self.mbox.next() is None) self.assert_(self.mbox.next() is None)
Example #6
Source File: test_mailbox.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_nonempty_maildir_new(self): self.createMessage("new") self.mbox = mailbox.Maildir(test_support.TESTFN) #self.assert_(len(self.mbox.boxes) == 1) self.assert_(self.mbox.next() is not None) self.assert_(self.mbox.next() is None) self.assert_(self.mbox.next() is None)
Example #7
Source File: test_mailbox.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_lock_unlock(self): # Lock and unlock the mailbox. For Maildir, this does nothing. self._box.lock() self._box.unlock()
Example #8
Source File: test_mailbox.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_initialize_existing(self): # Initialize an existing mailbox self.tearDown() for subdir in '', 'tmp', 'new', 'cur': os.mkdir(os.path.normpath(os.path.join(self._path, subdir))) self._box = mailbox.Maildir(self._path) self._check_basics(factory=rfc822.Message) self._box = mailbox.Maildir(self._path, factory=None) self._check_basics()
Example #9
Source File: test_mailbox.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_consistent_factory(self): # Add a message. msg = mailbox.MaildirMessage(self._template % 0) msg.set_subdir('cur') msg.set_flags('RF') key = self._box.add(msg) # Create new mailbox with class FakeMessage(mailbox.MaildirMessage): pass box = mailbox.Maildir(self._path, factory=FakeMessage) box.colon = self._box.colon msg2 = box.get_message(key) self.assert_(isinstance(msg2, FakeMessage))
Example #10
Source File: test_old_mailbox.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_nonempty_maildir_both(self): self.createMessage("cur") self.createMessage("new") self.mbox = mailbox.Maildir(test_support.TESTFN) self.assert_(len(self.mbox) == 2) self.assert_and_close(self.mbox.next()) self.assert_and_close(self.mbox.next()) self.assert_(self.mbox.next() is None) self.assert_(self.mbox.next() is None)
Example #11
Source File: test_mailbox.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_empty_maildir(self): """Test an empty maildir mailbox""" # Test for regression on bug #117490: # Make sure the boxes attribute actually gets set. self.mbox = mailbox.Maildir(test_support.TESTFN) #self.assert_(hasattr(self.mbox, "boxes")) #self.assert_(len(self.mbox.boxes) == 0) self.assert_(self.mbox.next() is None) self.assert_(self.mbox.next() is None)
Example #12
Source File: test_mailbox.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_consistent_factory(self): # Add a message. msg = mailbox.MaildirMessage(self._template % 0) msg.set_subdir('cur') msg.set_flags('RF') key = self._box.add(msg) # Create new mailbox with class FakeMessage(mailbox.MaildirMessage): pass box = mailbox.Maildir(self._path, factory=FakeMessage) box.colon = self._box.colon msg2 = box.get_message(key) self.assertIsInstance(msg2, FakeMessage)
Example #13
Source File: test_mailbox.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_nonempty_maildir_both(self): self.createMessage("cur") self.createMessage("new") self.mbox = mailbox.Maildir(test_support.TESTFN) #self.assertEqual(len(self.mbox.boxes), 2) msg = self.mbox.next() self.assertIsNotNone(msg) msg.fp.close() msg = self.mbox.next() self.assertIsNotNone(msg) msg.fp.close() self.assertIsNone(self.mbox.next()) self.assertIsNone(self.mbox.next())
Example #14
Source File: test_mailbox.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_nonempty_maildir_cur(self): self.createMessage("cur") self.mbox = mailbox.Maildir(test_support.TESTFN) #self.assertEqual(len(self.mbox.boxes), 1) msg = self.mbox.next() self.assertIsNotNone(msg) msg.fp.close() self.assertIsNone(self.mbox.next()) self.assertIsNone(self.mbox.next())
Example #15
Source File: test_mailbox.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_empty_maildir(self): """Test an empty maildir mailbox""" # Test for regression on bug #117490: # Make sure the boxes attribute actually gets set. self.mbox = mailbox.Maildir(test_support.TESTFN) #self.assertTrue(hasattr(self.mbox, "boxes")) #self.assertEqual(len(self.mbox.boxes), 0) self.assertIsNone(self.mbox.next()) self.assertIsNone(self.mbox.next())
Example #16
Source File: test_mailbox.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_folder_file_perms(self): # From bug #3228, we want to verify that the file created inside a Maildir # subfolder isn't marked as executable. orig_umask = os.umask(0) try: subfolder = self._box.add_folder('subfolder') finally: os.umask(orig_umask) path = os.path.join(subfolder._path, 'maildirfolder') st = os.stat(path) perms = st.st_mode self.assertFalse((perms & 0111)) # Execute bits should all be off.
Example #17
Source File: test_mailbox.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_initialize_existing(self): # Initialize an existing mailbox self.tearDown() for subdir in '', 'tmp', 'new', 'cur': os.mkdir(os.path.normpath(os.path.join(self._path, subdir))) self._box = mailbox.Maildir(self._path) self._check_basics()
Example #18
Source File: test_mailbox.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_initialize_existing(self): # Initialize an existing mailbox self.tearDown() for subdir in '', 'tmp', 'new', 'cur': os.mkdir(os.path.normpath(os.path.join(self._path, subdir))) self._box = mailbox.Maildir(self._path) self._check_basics(factory=rfc822.Message) self._box = mailbox.Maildir(self._path, factory=None) self._check_basics()
Example #19
Source File: test_mailbox.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_consistent_factory(self): # Add a message. msg = mailbox.MaildirMessage(self._template % 0) msg.set_subdir('cur') msg.set_flags('RF') key = self._box.add(msg) # Create new mailbox with class FakeMessage(mailbox.MaildirMessage): pass box = mailbox.Maildir(self._path, factory=FakeMessage) box.colon = self._box.colon msg2 = box.get_message(key) self.assertIsInstance(msg2, FakeMessage)
Example #20
Source File: test_old_mailbox.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_nonempty_maildir_both(self): self.createMessage("cur") self.createMessage("new") self.mbox = mailbox.Maildir(test_support.TESTFN) self.assertTrue(len(self.mbox) == 2) msg = self.mbox.next() self.assertTrue(msg is not None) msg.fp.close() msg = self.mbox.next() self.assertTrue(msg is not None) msg.fp.close() self.assertTrue(self.mbox.next() is None) self.assertTrue(self.mbox.next() is None)
Example #21
Source File: test_old_mailbox.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_nonempty_maildir_new(self): self.createMessage("new") self.mbox = mailbox.Maildir(test_support.TESTFN) self.assertTrue(len(self.mbox) == 1) msg = self.mbox.next() self.assertTrue(msg is not None) msg.fp.close() self.assertTrue(self.mbox.next() is None) self.assertTrue(self.mbox.next() is None)
Example #22
Source File: test_old_mailbox.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_nonempty_maildir_cur(self): self.createMessage("cur") self.mbox = mailbox.Maildir(test_support.TESTFN) self.assertTrue(len(self.mbox) == 1) msg = self.mbox.next() self.assertTrue(msg is not None) msg.fp.close() self.assertTrue(self.mbox.next() is None) self.assertTrue(self.mbox.next() is None)
Example #23
Source File: test_old_mailbox.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_empty_maildir(self): """Test an empty maildir mailbox""" # Test for regression on bug #117490: self.mbox = mailbox.Maildir(test_support.TESTFN) self.assertTrue(len(self.mbox) == 0) self.assertTrue(self.mbox.next() is None) self.assertTrue(self.mbox.next() is None)
Example #24
Source File: test_mailbox.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_nonempty_maildir_both(self): self.createMessage("cur") self.createMessage("new") self.mbox = mailbox.Maildir(support.TESTFN) #self.assertEqual(len(self.mbox.boxes), 2) self.assertIsNotNone(self.mbox.next()) self.assertIsNotNone(self.mbox.next()) self.assertIsNone(self.mbox.next()) self.assertIsNone(self.mbox.next()) ## End: tests from the original module (for backward compatibility).
Example #25
Source File: test_mailbox.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_nonempty_maildir_new(self): self.createMessage("new") self.mbox = mailbox.Maildir(support.TESTFN) #self.assertEqual(len(self.mbox.boxes), 1) self.assertIsNotNone(self.mbox.next()) self.assertIsNone(self.mbox.next()) self.assertIsNone(self.mbox.next())
Example #26
Source File: test_mailbox.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_nonempty_maildir_cur(self): self.createMessage("cur") self.mbox = mailbox.Maildir(support.TESTFN) #self.assertEqual(len(self.mbox.boxes), 1) self.assertIsNotNone(self.mbox.next()) self.assertIsNone(self.mbox.next()) self.assertIsNone(self.mbox.next())
Example #27
Source File: test_mailbox.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_folder_file_perms(self): # From bug #3228, we want to verify that the file created inside a Maildir # subfolder isn't marked as executable. orig_umask = os.umask(0) try: subfolder = self._box.add_folder('subfolder') finally: os.umask(orig_umask) path = os.path.join(subfolder._path, 'maildirfolder') st = os.stat(path) perms = st.st_mode self.assertFalse((perms & 0o111)) # Execute bits should all be off.
Example #28
Source File: test_mailbox.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_lock_unlock(self): # Lock and unlock the mailbox. For Maildir, this does nothing. self._box.lock() self._box.unlock()
Example #29
Source File: test_mailbox.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_initialize_existing(self): # Initialize an existing mailbox self.tearDown() for subdir in '', 'tmp', 'new', 'cur': os.mkdir(os.path.normpath(os.path.join(self._path, subdir))) self._box = mailbox.Maildir(self._path) self._check_basics()
Example #30
Source File: test_mailbox.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_initialize_new(self): # Initialize a non-existent mailbox self.tearDown() self._box = mailbox.Maildir(self._path) self._check_basics() self._delete_recursively(self._path) self._box = self._factory(self._path, factory=None) self._check_basics()