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)
| 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. |
no test coverage detected