CHANGELOG: Document this branch's atomic saves
[rss2email.git] / rss2email / post_process / downcase.py
1 # Copyright (C) 2013 W. Trevor King <wking@tremily.us>
2 #
3 # This file is part of rss2email.
4 #
5 # rss2email is free software: you can redistribute it and/or modify it under
6 # the terms of the GNU General Public License as published by the Free Software
7 # Foundation, either version 2 of the License, or (at your option) version 3 of
8 # the License.
9 #
10 # rss2email is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License along with
15 # rss2email.  If not, see <http://www.gnu.org/licenses/>.
16
17 """A text-manipulation hook for testing the post-processing infrastructure
18 """
19
20 def _downcase_payload(part):
21     if part.get_content_type() != 'text/plain':
22         return
23     payload = part.get_payload()
24     part.set_payload(payload.lower())
25
26 def downcase_message(message, **kwargs):
27     """Downcase the message body (for testing)
28     """
29     if message.is_multipart():
30         for part in message.walk():
31             if part.get_content_type() == 'text/plain':
32                 _downcase_payload(part)
33     else:
34         _downcase_payload(message)
35     return message