MCPcopy Index your code
hub / github.com/python/cpython / parse

Method parse

Lib/email/parser.py:41–54  ·  view source on GitHub ↗

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

(self, fp, headersonly=False)

Source from the content-addressed store, hash-verified

39 self.policy = policy
40
41 def parse(self, fp, headersonly=False):
42 """Create a message structure from the data in a file.
43
44 Reads all the data from the file and returns the root of the message
45 structure. Optional headersonly is a flag specifying whether to stop
46 parsing after reading the headers or not. The default is False,
47 meaning it parses the entire contents of the file.
48 """
49 feedparser = FeedParser(self._class, policy=self.policy)
50 if headersonly:
51 feedparser._set_headersonly()
52 while data := fp.read(8192):
53 feedparser.feed(data)
54 return feedparser.close()
55
56 def parsestr(self, text, headersonly=False):
57 """Create a message structure from a string.

Callers 15

parsestrMethod · 0.95
_signature_fromstrFunction · 0.45
_should_show_caretsMethod · 0.45
_template_to_astFunction · 0.45
_create_treeFunction · 0.45
message_from_fileFunction · 0.45
message_from_binary_fileFunction · 0.45
parseMethod · 0.45
parseMethod · 0.45
parseMethod · 0.45
validateMethod · 0.45

Calls 5

_set_headersonlyMethod · 0.95
feedMethod · 0.95
closeMethod · 0.95
FeedParserClass · 0.90
readMethod · 0.45

Tested by

no test coverage detected