本文整理汇总了Python中email.generator.DecodedGenerator方法的典型用法代码示例。如果您正苦于以下问题:Python generator.DecodedGenerator方法的具体用法?Python generator.DecodedGenerator怎么用?Python generator.DecodedGenerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类email.generator
的用法示例。
在下文中一共展示了generator.DecodedGenerator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_decoded_generator
# 需要导入模块: from email import generator [as 别名]
# 或者: from email.generator import DecodedGenerator [as 别名]
def test_decoded_generator(self):
eq = self.assertEqual
msg = self._msgobj('msg_07.txt')
fp = openfile('msg_17.txt')
try:
text = fp.read()
finally:
fp.close()
s = StringIO()
g = DecodedGenerator(s)
g.flatten(msg)
eq(s.getvalue(), text)
示例2: test_decoded_generator
# 需要导入模块: from email import generator [as 别名]
# 或者: from email.generator import DecodedGenerator [as 别名]
def test_decoded_generator(self):
eq = self.assertEqual
msg = self._msgobj('msg_07.txt')
with openfile('msg_17.txt') as fp:
text = fp.read()
s = StringIO()
g = DecodedGenerator(s)
g.flatten(msg)
eq(s.getvalue(), text)
示例3: test_decoded_generator_emits_unicode_body
# 需要导入模块: from email import generator [as 别名]
# 或者: from email.generator import DecodedGenerator [as 别名]
def test_decoded_generator_emits_unicode_body(self):
m = email.message_from_bytes(self.latin_bin_msg)
out = StringIO()
email.generator.DecodedGenerator(out).flatten(m)
#DecodedHeader output contains an extra blank line compared
#to the input message. RDM: not sure if this is a bug or not,
#but it is not specific to the 8bit->7bit conversion.
self.assertEqual(out.getvalue(),
self.latin_bin_msg.decode('latin-1')+'\n')