rss2email/post_process/downcase.py: Move my test hook into Arun's directory
authorW. Trevor King <wking@tremily.us>
Fri, 10 May 2013 08:39:33 +0000 (04:39 -0400)
committerW. Trevor King <wking@tremily.us>
Fri, 10 May 2013 08:57:29 +0000 (04:57 -0400)
All the built-in hooks should live in the same sub-package.  The
`post_process` name Arun used is more descriptive than my `hook`, so
move my downcase code there.

Signed-off-by: W. Trevor King <wking@tremily.us>
rss2email/config.py
rss2email/hook.py [deleted file]
rss2email/post_process/__init__.py
rss2email/post_process/downcase.py [new file with mode: 0644]
test/allthingsrss/2.config

index 2b9471986582a2b5a55d77c9247f5d9501537666..6eba7ec7263a8bca5fa98a42047a575d33b3f4b2 100644 (file)
@@ -93,7 +93,7 @@ CONFIG['DEFAULT'] = _collections.OrderedDict((
         # first character set that works.
         ('encodings', 'US-ASCII, ISO-8859-1, UTF-8, BIG5, ISO-2022-JP'),
         # User processing hooks.  Note the space after the module name.
-        # Example: post-process = 'rss2email.hook downcase_message'
+        # Example: post-process = 'rss2email.post_process.downcase downcase_message'
         ('post-process', ''),
         ## HTML conversion
         # True: Send text/html messages when possible.
diff --git a/rss2email/hook.py b/rss2email/hook.py
deleted file mode 100644 (file)
index 45542d5..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright
-
-"""Useful hooks for post processing messages
-
-Along with some less useful hooks for testing the post-processing
-infrastructure.  The hook, when set, is called by ``Feed._process()``
-with the following keyword arguments:
-
-feed:
-  The ``rss2email.feed.Feed`` instance that generated the message.
-parsed:
-  The parsed feed as returned by ``feedparser.parse``
-entry:
-  The entry from ``parsed`` that lead to the current message.
-guid:
-  The feed's view of the identity of the current entry.
-message:
-  The ``email.message.Message`` instance that rss2email would send if
-  the post-processing hook were disabled.
-
-Post processing hooks should return the possibly altered message, or
-return ``None`` to indicate that the message should not be sent.
-"""
-
-def _downcase_payload(part):
-    if part.get_content_type() != 'text/plain':
-        return
-    payload = part.get_payload()
-    part.set_payload(payload.lower())
-
-def downcase_message(message, **kwargs):
-    """Downcase the message body (for testing)
-    """
-    if message.is_multipart():
-        for part in message.walk():
-            if part.get_content_type() == 'text/plain':
-                _downcase_payload(part)
-    else:
-        _downcase_payload(message)
-    return message
index d011b39f0f6758d050b93df093dbca1cc0a96437..3632dbbade7b3ad7df5b63005759c7c6fa629722 100644 (file)
@@ -1,4 +1,22 @@
 # Copyright
 
-"""Post processing functions for manipulating entry messages
+"""Post-processing functions for manipulating entry messages
+
+A post-processing hook, when set, is called by ``Feed._process()``
+with the following keyword arguments:
+
+feed:
+  The ``rss2email.feed.Feed`` instance that generated the message.
+parsed:
+  The parsed feed as returned by ``feedparser.parse``
+entry:
+  The entry from ``parsed`` that lead to the current message.
+guid:
+  The feed's view of the identity of the current entry.
+message:
+  The ``email.message.Message`` instance that rss2email would send if
+  the post-processing hook were disabled.
+
+Post-processing hooks should return the possibly altered message, or
+return ``None`` to indicate that the message should not be sent.
 """
diff --git a/rss2email/post_process/downcase.py b/rss2email/post_process/downcase.py
new file mode 100644 (file)
index 0000000..fbaa899
--- /dev/null
@@ -0,0 +1,21 @@
+# Copyright
+
+"""A text-manipulation hook for testing the post-processing infrastructure
+"""
+
+def _downcase_payload(part):
+    if part.get_content_type() != 'text/plain':
+        return
+    payload = part.get_payload()
+    part.set_payload(payload.lower())
+
+def downcase_message(message, **kwargs):
+    """Downcase the message body (for testing)
+    """
+    if message.is_multipart():
+        for part in message.walk():
+            if part.get_content_type() == 'text/plain':
+                _downcase_payload(part)
+    else:
+        _downcase_payload(message)
+    return message
index 59a442761ec2fd26e64ce0dcb8ec651e3c8e38db..8c80dc70691ee335e5bd32410a379d1acf83b9b6 100644 (file)
@@ -1,4 +1,4 @@
 [DEFAULT]
 to = a@b.com
 date-header = True
-post-process = rss2email.hook downcase_message
+post-process = rss2email.post_process.downcase downcase_message