Python email.feedparser() Examples
The following are 27
code examples of email.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
, or try the search function
.
Example #1
Source File: test_email.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_push_random(self): from email.feedparser import BufferedSubFile, NeedMoreData n = 10000 chunksize = 5 chars = 'abcd \t\r\n' s = ''.join(choice(chars) for i in range(n)) + '\n' target = s.splitlines(True) bsf = BufferedSubFile() lines = [] for i in range(0, len(s), chunksize): chunk = s[i:i+chunksize] bsf.push(chunk) lines.extend(iter(bsf.readline, NeedMoreData)) self.assertEqual(lines, target)
Example #2
Source File: test_email.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def test_CRLFLF_at_end_of_part(self): # issue 5610: feedparser should not eat two chars from body part ending # with "\r\n\n". m = ( "From: foo@bar.com\n" "To: baz\n" "Mime-Version: 1.0\n" "Content-Type: multipart/mixed; boundary=BOUNDARY\n" "\n" "--BOUNDARY\n" "Content-Type: text/plain\n" "\n" "body ending with CRLF newline\r\n" "\n" "--BOUNDARY--\n" ) msg = email.message_from_string(m) self.assertTrue(msg.get_payload(0).get_payload().endswith('\r\n'))
Example #3
Source File: test_email.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def test_CRLFLF_at_end_of_part(self): # issue 5610: feedparser should not eat two chars from body part ending # with "\r\n\n". m = ( "From: foo@bar.com\n" "To: baz\n" "Mime-Version: 1.0\n" "Content-Type: multipart/mixed; boundary=BOUNDARY\n" "\n" "--BOUNDARY\n" "Content-Type: text/plain\n" "\n" "body ending with CRLF newline\r\n" "\n" "--BOUNDARY--\n" ) msg = email.message_from_string(m) self.assertTrue(msg.get_payload(0).get_payload().endswith('\r\n'))
Example #4
Source File: test_email.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def test_CRLFLF_at_end_of_part(self): # issue 5610: feedparser should not eat two chars from body part ending # with "\r\n\n". m = ( "From: foo@bar.com\n" "To: baz\n" "Mime-Version: 1.0\n" "Content-Type: multipart/mixed; boundary=BOUNDARY\n" "\n" "--BOUNDARY\n" "Content-Type: text/plain\n" "\n" "body ending with CRLF newline\r\n" "\n" "--BOUNDARY--\n" ) msg = email.message_from_string(m) self.assertTrue(msg.get_payload(0).get_payload().endswith('\r\n'))
Example #5
Source File: test_email.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def test_CRLFLF_at_end_of_part(self): # issue 5610: feedparser should not eat two chars from body part ending # with "\r\n\n". m = ( "From: foo@bar.com\n" "To: baz\n" "Mime-Version: 1.0\n" "Content-Type: multipart/mixed; boundary=BOUNDARY\n" "\n" "--BOUNDARY\n" "Content-Type: text/plain\n" "\n" "body ending with CRLF newline\r\n" "\n" "--BOUNDARY--\n" ) msg = email.message_from_string(m) self.assertTrue(msg.get_payload(0).get_payload().endswith('\r\n'))
Example #6
Source File: test_email.py From datafari with Apache License 2.0 | 6 votes |
def test_CRLFLF_at_end_of_part(self): # issue 5610: feedparser should not eat two chars from body part ending # with "\r\n\n". m = ( "From: foo@bar.com\n" "To: baz\n" "Mime-Version: 1.0\n" "Content-Type: multipart/mixed; boundary=BOUNDARY\n" "\n" "--BOUNDARY\n" "Content-Type: text/plain\n" "\n" "body ending with CRLF newline\r\n" "\n" "--BOUNDARY--\n" ) msg = email.message_from_string(m) self.assertTrue(msg.get_payload(0).get_payload().endswith('\r\n'))
Example #7
Source File: test_email.py From datafari with Apache License 2.0 | 6 votes |
def test_push_random(self): from email.feedparser import BufferedSubFile, NeedMoreData n = 10000 chunksize = 5 chars = 'abcd \t\r\n' s = ''.join(choice(chars) for i in range(n)) + '\n' target = s.splitlines(True) bsf = BufferedSubFile() lines = [] for i in range(0, len(s), chunksize): chunk = s[i:i+chunksize] bsf.push(chunk) lines.extend(iter(bsf.readline, NeedMoreData)) self.assertEqual(lines, target)
Example #8
Source File: test_email.py From ironpython3 with Apache License 2.0 | 6 votes |
def test_CRLFLF_at_end_of_part(self): # issue 5610: feedparser should not eat two chars from body part ending # with "\r\n\n". m = ( "From: foo@bar.com\n" "To: baz\n" "Mime-Version: 1.0\n" "Content-Type: multipart/mixed; boundary=BOUNDARY\n" "\n" "--BOUNDARY\n" "Content-Type: text/plain\n" "\n" "body ending with CRLF newline\r\n" "\n" "--BOUNDARY--\n" ) msg = email.message_from_string(m) self.assertTrue(msg.get_payload(0).get_payload().endswith('\r\n'))
Example #9
Source File: test_email.py From ironpython3 with Apache License 2.0 | 6 votes |
def test_push_random(self): from email.feedparser import BufferedSubFile, NeedMoreData n = 10000 chunksize = 5 chars = 'abcd \t\r\n' s = ''.join(choice(chars) for i in range(n)) + '\n' target = s.splitlines(True) bsf = BufferedSubFile() lines = [] for i in range(0, len(s), chunksize): chunk = s[i:i+chunksize] bsf.push(chunk) lines.extend(iter(bsf.readline, NeedMoreData)) self.assertEqual(lines, target)
Example #10
Source File: test_email.py From oss-ftp with MIT License | 6 votes |
def test_CRLFLF_at_end_of_part(self): # issue 5610: feedparser should not eat two chars from body part ending # with "\r\n\n". m = ( "From: foo@bar.com\n" "To: baz\n" "Mime-Version: 1.0\n" "Content-Type: multipart/mixed; boundary=BOUNDARY\n" "\n" "--BOUNDARY\n" "Content-Type: text/plain\n" "\n" "body ending with CRLF newline\r\n" "\n" "--BOUNDARY--\n" ) msg = email.message_from_string(m) self.assertTrue(msg.get_payload(0).get_payload().endswith('\r\n'))
Example #11
Source File: test_email.py From oss-ftp with MIT License | 6 votes |
def test_push_random(self): from email.feedparser import BufferedSubFile, NeedMoreData n = 10000 chunksize = 5 chars = 'abcd \t\r\n' s = ''.join(choice(chars) for i in range(n)) + '\n' target = s.splitlines(True) bsf = BufferedSubFile() lines = [] for i in range(0, len(s), chunksize): chunk = s[i:i+chunksize] bsf.push(chunk) lines.extend(iter(bsf.readline, NeedMoreData)) self.assertEqual(lines, target)
Example #12
Source File: test_email.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_CRLFLF_at_end_of_part(self): # issue 5610: feedparser should not eat two chars from body part ending # with "\r\n\n". m = ( "From: foo@bar.com\n" "To: baz\n" "Mime-Version: 1.0\n" "Content-Type: multipart/mixed; boundary=BOUNDARY\n" "\n" "--BOUNDARY\n" "Content-Type: text/plain\n" "\n" "body ending with CRLF newline\r\n" "\n" "--BOUNDARY--\n" ) msg = email.message_from_string(m) self.assertTrue(msg.get_payload(0).get_payload().endswith('\r\n'))
Example #13
Source File: test_email.py From BinderFilter with MIT License | 6 votes |
def test_CRLFLF_at_end_of_part(self): # issue 5610: feedparser should not eat two chars from body part ending # with "\r\n\n". m = ( "From: foo@bar.com\n" "To: baz\n" "Mime-Version: 1.0\n" "Content-Type: multipart/mixed; boundary=BOUNDARY\n" "\n" "--BOUNDARY\n" "Content-Type: text/plain\n" "\n" "body ending with CRLF newline\r\n" "\n" "--BOUNDARY--\n" ) msg = email.message_from_string(m) self.assertTrue(msg.get_payload(0).get_payload().endswith('\r\n'))
Example #14
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 #15
Source File: test_email.py From CTFCrackTools with GNU General Public License v3.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 while True: ol = bsf.readline() if ol == NeedMoreData: break om.append(ol) n1 += 1 self.assertTrue(n == n1) self.assertTrue(len(om) == nt) self.assertTrue(''.join([il for il, n in imt]) == ''.join(om))
Example #16
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 #17
Source File: test_email.py From CTFCrackTools with GNU General Public License v3.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 while True: ol = bsf.readline() if ol == NeedMoreData: break om.append(ol) n1 += 1 self.assertTrue(n == n1) self.assertTrue(len(om) == nt) self.assertTrue(''.join([il for il, n in imt]) == ''.join(om))
Example #18
Source File: test_email.py From CTFCrackTools-V2 with GNU General Public License v3.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 while True: ol = bsf.readline() if ol == NeedMoreData: break om.append(ol) n1 += 1 self.assertTrue(n == n1) self.assertTrue(len(om) == nt) self.assertTrue(''.join([il for il, n in imt]) == ''.join(om))
Example #19
Source File: test_email.py From BinderFilter 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 while True: ol = bsf.readline() if ol == NeedMoreData: break om.append(ol) n1 += 1 self.assertTrue(n == n1) self.assertTrue(len(om) == nt) self.assertTrue(''.join([il for il, n in imt]) == ''.join(om))
Example #20
Source File: test_email.py From CTFCrackTools-V2 with GNU General Public License v3.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 while True: ol = bsf.readline() if ol == NeedMoreData: break om.append(ol) n1 += 1 self.assertTrue(n == n1) self.assertTrue(len(om) == nt) self.assertTrue(''.join([il for il, n in imt]) == ''.join(om))
Example #21
Source File: test_email.py From datafari 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 #22
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 #23
Source File: test_email.py From datafari 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 #24
Source File: test_email.py From ironpython3 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 #25
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 #26
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 #27
Source File: test_email.py From ironpython3 with Apache License 2.0 | 5 votes |
def test__all__(self): module = __import__('email') self.assertEqual(sorted(module.__all__), [ 'base64mime', 'charset', 'encoders', 'errors', 'feedparser', 'generator', 'header', 'iterators', 'message', 'message_from_binary_file', 'message_from_bytes', 'message_from_file', 'message_from_string', 'mime', 'parser', 'quoprimime', 'utils', ])