To: a@b.com
Subject: Version 2.67 Released
Date: Tue, 21 Sep 2010 16:55:07 -0000
+Message-ID: <...@dev.null.invalid>
User-Agent: rss2email
X-RSS-Feed: allthingsrss/feed.atom
X-RSS-ID: http://www.allthingsrss.com/rss2email/?p=62
To: a@b.com
Subject: Version 2.68 Released with Actual New Features
Date: Fri, 01 Oct 2010 18:21:26 -0000
+Message-ID: <...@dev.null.invalid>
User-Agent: rss2email
X-RSS-Feed: allthingsrss/feed.atom
X-RSS-ID: http://www.allthingsrss.com/rss2email/?p=72
To: a@b.com
Subject: How to Read RSS Feeds in Emacs
Date: Fri, 05 Nov 2010 17:36:14 -0000
+Message-ID: <...@dev.null.invalid>
User-Agent: rss2email
X-RSS-Feed: allthingsrss/feed.atom
X-RSS-ID: http://www.allthingsrss.com/rss2email/?p=79
To: a@b.com
Subject: Version 2.69 Released
Date: Fri, 12 Nov 2010 18:45:08 -0000
+Message-ID: <...@dev.null.invalid>
User-Agent: rss2email
X-RSS-Feed: allthingsrss/feed.atom
X-RSS-ID: http://www.allthingsrss.com/rss2email/?p=85
To: a@b.com
Subject: Minor Correction to v2.69 Packages
Date: Fri, 10 Dec 2010 17:47:58 -0000
+Message-ID: <...@dev.null.invalid>
User-Agent: rss2email
X-RSS-Feed: allthingsrss/feed.atom
X-RSS-ID: http://www.allthingsrss.com/rss2email/?p=88
To: a@b.com
Subject: Minor correction to the minor correction: v2.69a released
Date: Mon, 13 Dec 2010 18:04:20 -0000
+Message-ID: <...@dev.null.invalid>
User-Agent: rss2email
X-RSS-Feed: allthingsrss/feed.atom
X-RSS-ID: http://www.allthingsrss.com/rss2email/?p=95
To: a@b.com
Subject: Mac OS X and rss2email are Compatible
Date: Fri, 17 Dec 2010 20:54:27 -0000
+Message-ID: <...@dev.null.invalid>
User-Agent: rss2email
X-RSS-Feed: allthingsrss/feed.atom
X-RSS-ID: http://www.allthingsrss.com/rss2email/?p=99
To: a@b.com
Subject: Version 2.70 Released
Date: Tue, 21 Dec 2010 20:00:49 -0000
+Message-ID: <...@dev.null.invalid>
User-Agent: rss2email
X-RSS-Feed: allthingsrss/feed.atom
X-RSS-ID: http://www.allthingsrss.com/rss2email/?p=106
To: a@b.com
Subject: Version 2.71 Release plus Other Major Updates
Date: Fri, 04 Mar 2011 18:03:11 -0000
+Message-ID: <...@dev.null.invalid>
User-Agent: rss2email
X-RSS-Feed: allthingsrss/feed.atom
X-RSS-ID: http://www.allthingsrss.com/rss2email/?p=123
To: a@b.com
Subject: Mac OS, rss2email and scheduling with launchd
Date: Tue, 23 Aug 2011 15:57:37 -0000
+Message-ID: <...@dev.null.invalid>
User-Agent: rss2email
X-RSS-Feed: allthingsrss/feed.atom
X-RSS-ID: http://www.allthingsrss.com/rss2email/?p=131
import io as _io
import logging as _logging
import os as _os
+import re as _re
import rss2email as _rss2email
+import rss2email.config as _rss2email_config
+import rss2email.feed as _rss2email_feed
# Get a copy of the internal rss2email.CONFIG for copying
_stringio = _io.StringIO()
-_rss2email.CONFIG.write(_stringio)
+_rss2email_config.CONFIG.write(_stringio)
BASE_CONFIG_STRING = _stringio.getvalue()
del _stringio
+MESSAGE_ID_REGEXP = _re.compile(
+ '^Message-ID: <[^@]*@dev.null.invalid>$', _re.MULTILINE)
+
class Send (list):
def __call__(self, sender, message):
return '\n'.join(chunks)
+def clean_result(text):
+ """Cleanup dynamic portions of the generated email headers
+
+ >>> text = (
+ ... 'Date: Tue, 23 Aug 2011 15:57:37 -0000\\n'
+ ... 'Message-ID: <9dff03db-f5a7@dev.null.invalid>\\n'
+ ... 'User-Agent: rss2email\\n'
+ ... )
+ >>> print(clean_result(text).rstrip())
+ Date: Tue, 23 Aug 2011 15:57:37 -0000
+ Message-ID: <...@dev.null.invalid>
+ User-Agent: rss2email
+ """
+ return MESSAGE_ID_REGEXP.sub('Message-ID: <...@dev.null.invalid>', text)
+
def test(dirname=None, config_path=None, force=False):
if dirname is None:
dirname = _os.path.dirname(config_path)
return
feed_path = _glob.glob(_os.path.join(dirname, 'feed.*'))[0]
_rss2email.LOG.info('testing {}'.format(config_path))
- config = _rss2email.Config()
+ config = _rss2email_config.Config()
config.read_string(BASE_CONFIG_STRING)
read_paths = config.read([config_path])
- feed = _rss2email.Feed(name='test', url=feed_path, config=config)
+ feed = _rss2email_feed.Feed(name='test', url=feed_path, config=config)
expected_path = config_path.replace('config', 'expected')
with open(expected_path, 'r') as f:
- expected = f.read()
+ expected = clean_result(f.read())
feed._send = Send()
feed.run()
generated = feed._send.as_string()
if force:
with open(expected_path, 'w') as f:
f.write(generated)
+ generated = clean_result(generated)
if generated != expected:
diff_lines = _difflib.unified_diff(
expected.splitlines(), generated.splitlines(),