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


Python errors.MultipartConversionError方法代碼示例

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


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

示例1: attach

# 需要導入模塊: from email import errors [as 別名]
# 或者: from email.errors import MultipartConversionError [as 別名]
def attach(self, payload):
        """
        Add the C{payload} to the current payload list.

        Also prevent from adding payloads with wrong Content-Type and from
        exceeding a maximum of 2 payloads.

        :param payload: The payload to be attached.
        :type payload: email.message.Message
        """
        # second payload's content type must be equal to the protocol
        # parameter given on object creation
        if len(self.get_payload()) == 1:
            if payload.get_content_type() != self.get_param('protocol'):
                raise errors.MultipartConversionError(
                    'Wrong content type %s.' % payload.get_content_type)
        # prevent from adding more payloads
        if len(self._payload) == 2:
            raise errors.MultipartConversionError(
                'Cannot have more than two subparts.')
        MIMEMultipart.attach(self, payload) 
開發者ID:leapcode,項目名稱:bitmask-dev,代碼行數:23,代碼來源:rfc3156.py

示例2: attach

# 需要導入模塊: from email import errors [as 別名]
# 或者: from email.errors import MultipartConversionError [as 別名]
def attach(self, payload):
        # The public API prohibits attaching multiple subparts to MIMEBase
        # derived subtypes since none of them are, by definition, of content
        # type multipart/*
        raise errors.MultipartConversionError(
            'Cannot attach additional subparts to non-multipart/*') 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:8,代碼來源:nonmultipart.py

示例3: test_bad_multipart

# 需要導入模塊: from email import errors [as 別名]
# 或者: from email.errors import MultipartConversionError [as 別名]
def test_bad_multipart(self):
        eq = self.assertEqual
        msg1 = Message()
        msg1['Subject'] = 'subpart 1'
        msg2 = Message()
        msg2['Subject'] = 'subpart 2'
        r = MIMEMessage(msg1)
        self.assertRaises(errors.MultipartConversionError, r.attach, msg2) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:10,代碼來源:test_email_renamed.py

示例4: test_bad_multipart

# 需要導入模塊: from email import errors [as 別名]
# 或者: from email.errors import MultipartConversionError [as 別名]
def test_bad_multipart(self):
        msg1 = Message()
        msg1['Subject'] = 'subpart 1'
        msg2 = Message()
        msg2['Subject'] = 'subpart 2'
        r = MIMEMessage(msg1)
        self.assertRaises(errors.MultipartConversionError, r.attach, msg2) 
開發者ID:IronLanguages,項目名稱:ironpython3,代碼行數:9,代碼來源:test_email.py


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