當前位置: 首頁>>代碼示例>>Python>>正文


Python mailbox.Maildir方法代碼示例

本文整理匯總了Python中mailbox.Maildir方法的典型用法代碼示例。如果您正苦於以下問題:Python mailbox.Maildir方法的具體用法?Python mailbox.Maildir怎麽用?Python mailbox.Maildir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mailbox的用法示例。


在下文中一共展示了mailbox.Maildir方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_folder_file_perms

# 需要導入模塊: import mailbox [as 別名]
# 或者: from mailbox import Maildir [as 別名]
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. 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:18,代碼來源:test_mailbox.py

示例2: test_empty_maildir

# 需要導入模塊: import mailbox [as 別名]
# 或者: from mailbox import Maildir [as 別名]
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) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:9,代碼來源:test_old_mailbox.py

示例3: test_nonempty_maildir_cur

# 需要導入模塊: import mailbox [as 別名]
# 或者: from mailbox import Maildir [as 別名]
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) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:11,代碼來源:test_old_mailbox.py

示例4: test_nonempty_maildir_new

# 需要導入模塊: import mailbox [as 別名]
# 或者: from mailbox import Maildir [as 別名]
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) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:11,代碼來源:test_old_mailbox.py

示例5: test_nonempty_maildir_both

# 需要導入模塊: import mailbox [as 別名]
# 或者: from mailbox import Maildir [as 別名]
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) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:15,代碼來源:test_old_mailbox.py

示例6: test_consistent_factory

# 需要導入模塊: import mailbox [as 別名]
# 或者: from mailbox import Maildir [as 別名]
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) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:16,代碼來源:test_mailbox.py

示例7: test_initialize_existing

# 需要導入模塊: import mailbox [as 別名]
# 或者: from mailbox import Maildir [as 別名]
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() 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:11,代碼來源:test_mailbox.py

示例8: test_lock_unlock

# 需要導入模塊: import mailbox [as 別名]
# 或者: from mailbox import Maildir [as 別名]
def test_lock_unlock(self):
        # Lock and unlock the mailbox. For Maildir, this does nothing.
        self._box.lock()
        self._box.unlock() 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:6,代碼來源:test_mailbox.py

示例9: test_folder_file_perms

# 需要導入模塊: import mailbox [as 別名]
# 或者: from mailbox import Maildir [as 別名]
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. 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:15,代碼來源:test_mailbox.py

示例10: test_empty_maildir

# 需要導入模塊: import mailbox [as 別名]
# 或者: from mailbox import Maildir [as 別名]
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()) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:11,代碼來源:test_mailbox.py

示例11: test_nonempty_maildir_cur

# 需要導入模塊: import mailbox [as 別名]
# 或者: from mailbox import Maildir [as 別名]
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()) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:11,代碼來源:test_mailbox.py

示例12: test_nonempty_maildir_both

# 需要導入模塊: import mailbox [as 別名]
# 或者: from mailbox import Maildir [as 別名]
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()) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:15,代碼來源:test_mailbox.py

示例13: test_empty_maildir

# 需要導入模塊: import mailbox [as 別名]
# 或者: from mailbox import Maildir [as 別名]
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.assertTrue(len(self.mbox.boxes) == 0)
        self.assertIs(self.mbox.next(), None)
        self.assertIs(self.mbox.next(), None) 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:11,代碼來源:test_mailbox.py

示例14: test_nonempty_maildir_cur

# 需要導入模塊: import mailbox [as 別名]
# 或者: from mailbox import Maildir [as 別名]
def test_nonempty_maildir_cur(self):
        self.createMessage("cur")
        self.mbox = mailbox.Maildir(test_support.TESTFN)
        #self.assertTrue(len(self.mbox.boxes) == 1)
        msg = self.mbox.next()
        self.assertIsNot(msg, None)
        msg.fp.close()
        self.assertIs(self.mbox.next(), None)
        self.assertIs(self.mbox.next(), None) 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:11,代碼來源:test_mailbox.py

示例15: test_nonempty_maildir_both

# 需要導入模塊: import mailbox [as 別名]
# 或者: from mailbox import Maildir [as 別名]
def test_nonempty_maildir_both(self):
        self.createMessage("cur")
        self.createMessage("new")
        self.mbox = mailbox.Maildir(test_support.TESTFN)
        #self.assertTrue(len(self.mbox.boxes) == 2)
        msg = self.mbox.next()
        self.assertIsNot(msg, None)
        msg.fp.close()
        msg = self.mbox.next()
        self.assertIsNot(msg, None)
        msg.fp.close()
        self.assertIs(self.mbox.next(), None)
        self.assertIs(self.mbox.next(), None) 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:15,代碼來源:test_mailbox.py


注:本文中的mailbox.Maildir方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。