Python email.feedparser.FeedParser() Examples
The following are 30
code examples of email.feedparser.FeedParser().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
email.feedparser
, or try the search function
.
Example #1
Source File: parser.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
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()
Example #2
Source File: parser.py From canape with GNU General Public License v3.0 | 6 votes |
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()
Example #3
Source File: parser.py From android_universal with MIT License | 6 votes |
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, policy=self.policy) if headersonly: feedparser._set_headersonly() while True: data = fp.read(8192) if not data: break feedparser.feed(data) return feedparser.close()
Example #4
Source File: parser.py From unity-python with MIT License | 6 votes |
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()
Example #5
Source File: parser.py From PokemonGo-DesktopMap with MIT License | 6 votes |
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()
Example #6
Source File: parser.py From Carnets with BSD 3-Clause "New" or "Revised" License | 6 votes |
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, policy=self.policy) if headersonly: feedparser._set_headersonly() while True: data = fp.read(8192) if not data: break feedparser.feed(data) return feedparser.close()
Example #7
Source File: parser.py From RevitBatchProcessor with GNU General Public License v3.0 | 6 votes |
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()
Example #8
Source File: parser.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
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()
Example #9
Source File: parser.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
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()
Example #10
Source File: parser.py From odoo13-x64 with GNU General Public License v3.0 | 6 votes |
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, policy=self.policy) if headersonly: feedparser._set_headersonly() while True: data = fp.read(8192) if not data: break feedparser.feed(data) return feedparser.close()
Example #11
Source File: parser.py From medicare-demo with Apache License 2.0 | 6 votes |
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()
Example #12
Source File: parser.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
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, policy=self.policy) if headersonly: feedparser._set_headersonly() while True: data = fp.read(8192) if not data: break feedparser.feed(data) return feedparser.close()
Example #13
Source File: parser.py From Splunking-Crime with GNU Affero General Public License v3.0 | 6 votes |
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()
Example #14
Source File: parser.py From datafari with Apache License 2.0 | 6 votes |
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()
Example #15
Source File: parser.py From meddle with MIT License | 6 votes |
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()
Example #16
Source File: parser.py From ironpython2 with Apache License 2.0 | 6 votes |
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()
Example #17
Source File: parser.py From ironpython3 with Apache License 2.0 | 6 votes |
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, policy=self.policy) if headersonly: feedparser._set_headersonly() while True: data = fp.read(8192) if not data: break feedparser.feed(data) return feedparser.close()
Example #18
Source File: parser.py From BinderFilter with MIT License | 6 votes |
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()
Example #19
Source File: parser.py From Computable with MIT License | 6 votes |
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()
Example #20
Source File: parser.py From Imogen with MIT License | 6 votes |
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, policy=self.policy) if headersonly: feedparser._set_headersonly() while True: data = fp.read(8192) if not data: break feedparser.feed(data) return feedparser.close()
Example #21
Source File: parser.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
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, policy=self.policy) if headersonly: feedparser._set_headersonly() while True: data = fp.read(8192) if not data: break feedparser.feed(data) return feedparser.close()
Example #22
Source File: parser.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
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()
Example #23
Source File: parser.py From pmatic with GNU General Public License v2.0 | 6 votes |
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()
Example #24
Source File: parser.py From oss-ftp with MIT License | 6 votes |
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()
Example #25
Source File: test_email.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_pushCR_LF(self): '''FeedParser BufferedSubFile.push() assumed it received complete line endings. A CR ending one push() followed by a LF starting the next push() added an empty line. ''' imt = [ ("a\r \n", 2), ("b", 0), ("c\n", 1), ("", 0), ("d\r\n", 1), ("e\r", 0), ("\nf", 1), ("\r\n", 1), ] from email.feedparser import BufferedSubFile, NeedMoreData bsf = BufferedSubFile() om = [] nt = 0 for il, n in imt: bsf.push(il) nt += n n1 = 0 for ol in iter(bsf.readline, NeedMoreData): om.append(ol) n1 += 1 self.assertEqual(n, n1) self.assertEqual(len(om), nt) self.assertEqual(''.join([il for il, n in imt]), ''.join(om))
Example #26
Source File: test_email.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_pushCR_LF(self): '''FeedParser BufferedSubFile.push() assumed it received complete line endings. A CR ending one push() followed by a LF starting the next push() added an empty line. ''' imt = [ ("a\r \n", 2), ("b", 0), ("c\n", 1), ("", 0), ("d\r\n", 1), ("e\r", 0), ("\nf", 1), ("\r\n", 1), ] from email.feedparser import BufferedSubFile, NeedMoreData bsf = BufferedSubFile() om = [] nt = 0 for il, n in imt: bsf.push(il) nt += n n1 = 0 for ol in iter(bsf.readline, NeedMoreData): om.append(ol) n1 += 1 self.assertEqual(n, n1) self.assertEqual(len(om), nt) self.assertEqual(''.join([il for il, n in imt]), ''.join(om))
Example #27
Source File: test_email.py From ironpython2 with Apache License 2.0 | 5 votes |
def parse(self, chunks): from email.feedparser import FeedParser feedparser = FeedParser() for chunk in chunks: feedparser.feed(chunk) return feedparser.close()
Example #28
Source File: test_email.py From oss-ftp with MIT License | 5 votes |
def test_pushCR_LF(self): '''FeedParser BufferedSubFile.push() assumed it received complete line endings. A CR ending one push() followed by a LF starting the next push() added an empty line. ''' imt = [ ("a\r \n", 2), ("b", 0), ("c\n", 1), ("", 0), ("d\r\n", 1), ("e\r", 0), ("\nf", 1), ("\r\n", 1), ] from email.feedparser import BufferedSubFile, NeedMoreData bsf = BufferedSubFile() om = [] nt = 0 for il, n in imt: bsf.push(il) nt += n n1 = 0 for ol in iter(bsf.readline, NeedMoreData): om.append(ol) n1 += 1 self.assertEqual(n, n1) self.assertEqual(len(om), nt) self.assertEqual(''.join([il for il, n in imt]), ''.join(om))
Example #29
Source File: test_email.py From oss-ftp with MIT License | 5 votes |
def parse(self, chunks): from email.feedparser import FeedParser feedparser = FeedParser() for chunk in chunks: feedparser.feed(chunk) return feedparser.close()
Example #30
Source File: cgi.py From python-compat-runtime with Apache License 2.0 | 5 votes |
def _ParseResponse(response): """Parses an HTTP response into a dict. Args: response: A cStringIO.StringIO (StringO) containing the HTTP response. Returns: A dict with fields: body: A str containing the body. headers: A list containing tuples (key, value) of key and value pairs. response_code: An int containing the HTTP response code. """ response.reset() parser = feedparser.FeedParser() parser._set_headersonly() while True: line = response.readline() if not feedparser.headerRE.match(line): if not feedparser.NLCRE.match(line): parser.feed(line) break parser.feed(line) parsed_response = parser.close() if 'Status' in parsed_response: status = int(parsed_response['Status'].split(' ', 1)[0]) del parsed_response['Status'] else: status = 200 return {'body': parsed_response.get_payload() + response.read(), 'headers': parsed_response.items(), 'response_code': status}