本文整理汇总了Python中email.feedparser.FeedParser._set_headersonly方法的典型用法代码示例。如果您正苦于以下问题:Python FeedParser._set_headersonly方法的具体用法?Python FeedParser._set_headersonly怎么用?Python FeedParser._set_headersonly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类email.feedparser.FeedParser
的用法示例。
在下文中一共展示了FeedParser._set_headersonly方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from email.feedparser import FeedParser [as 别名]
# 或者: from email.feedparser.FeedParser import _set_headersonly [as 别名]
def __init__(self, message=None):
"""Initialize a Message instance."""
feedparser = FeedParser(email.message.Message)
feedparser._set_headersonly()
data = message.read(4096)
feedparser.feed(data)
self._become_message(feedparser.close())
示例2: message_from_string_safe
# 需要导入模块: from email.feedparser import FeedParser [as 别名]
# 或者: from email.feedparser.FeedParser import _set_headersonly [as 别名]
def message_from_string_safe(text):
'handle failure by email standard library by bypassing StringIO blowup'
try: # use the standard library by default
return email.message_from_string(text)
except UnicodeEncodeError: # code copied from email.parser.Parser.parse()
feedparser = FeedParser(Message)
feedparser._set_headersonly()
feedparser.feed(text)
return feedparser.close()
示例3: parse
# 需要导入模块: from email.feedparser import FeedParser [as 别名]
# 或者: from email.feedparser.FeedParser import _set_headersonly [as 别名]
def parse(self, fp, headersonly=False):
feedparser = FeedParser(self._class, policy=self.policy)
if headersonly:
feedparser._set_headersonly()
while True:
data = fp.read(8192)
if not data:
break
feedparser.feed(data)
return feedparser.close()
示例4: parse
# 需要导入模块: from email.feedparser import FeedParser [as 别名]
# 或者: from email.feedparser.FeedParser import _set_headersonly [as 别名]
def parse(self, fp, headersonly=False):
"""Create a message structure from the data in a file.
Reads all the data from the file and returns the root of the message
structure. Optional headersonly is a flag specifying whether to stop
parsing after reading the headers or not. The default is False,
meaning it parses the entire contents of the file.
"""
feedparser = FeedParser(self._class)
if headersonly:
feedparser._set_headersonly()
while True:
data = fp.read(8192)
if not data:
break
feedparser.feed(data)
return feedparser.close()