1 # Copyright (C) 2004-2013 Aaron Swartz
4 # Dmitry Bogatov <KAction@gnu.org>
6 # Etienne Millon <me@emillon.org>
8 # Lindsey Smith <lindsey.smith@gmail.com>
10 # Martin 'Joey' Schulze
12 # W. Trevor King <wking@tremily.us>
14 # This file is part of rss2email.
16 # rss2email is free software: you can redistribute it and/or modify it under
17 # the terms of the GNU General Public License as published by the Free Software
18 # Foundation, either version 2 of the License, or (at your option) version 3 of
21 # rss2email is distributed in the hope that it will be useful, but WITHOUT ANY
22 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
23 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License along with
26 # rss2email. If not, see <http://www.gnu.org/licenses/>.
28 """Per-user rss2email configuration
31 import collections as _collections
32 import configparser as _configparser
34 import html2text as _html2text
37 class Config (_configparser.ConfigParser):
38 def __init__(self, dict_type=_collections.OrderedDict,
39 interpolation=_configparser.ExtendedInterpolation(),
41 super(Config, self).__init__(
42 dict_type=dict_type, interpolation=interpolation, **kwargs)
44 def _setup(self, section='DEFAULT'):
45 _html2text.UNICODE_SNOB = self.getboolean(
46 section, 'unicode-snob', fallback=False)
47 _html2text.LINKS_EACH_PARAGRAPH = self.getboolean(
48 section, 'links-after-each-paragaph', fallback=False)
49 _html2text.BODY_WIDTH = self.getint(section, 'body-width', fallback=0)
54 # setup defaults for feeds that don't customize
55 CONFIG['DEFAULT'] = _collections.OrderedDict((
57 # The email address messages are from by default
58 ('from', 'user@rss2email.invalid'),
59 # Transfer-Encoding. For local mailing it is safe and
60 # convient to use 8bit.
61 ('use-8bit', str(False)),
62 # True: Only use the 'from' address.
63 # False: Use the email address specified by the feed, when possible.
64 ('force-from', str(False)),
65 # True: Use the publisher's email if you can't find the author's.
66 # False: Just use the 'from' email instead.
67 ('use-publisher-email', str(False)),
68 # Only use the feed email address rather than friendly name
70 ('friendly-name', str(True)),
71 # Set this to default To email addresses.
75 # Set an HTTP proxy (e.g. 'http://your.proxy.here:8080/')
77 # Set the timeout (in seconds) for feed server response
78 ('feed-timeout', str(60)),
81 # True: Fetch, process, and email feeds.
82 # False: Don't fetch, process, or email feeds
83 ('active', str(True)),
84 # True: Send a single, multi-entry email per feed per rss2email run.
85 # False: Send a single email per entry.
86 ('digest', str(False)),
87 # True: Generate Date header based on item's date, when possible.
88 # False: Generate Date header based on time sent.
89 ('date-header', str(False)),
90 # A comma-delimited list of some combination of
91 # ('issued', 'created', 'modified', 'expired')
92 # expressing ordered list of preference in dates
93 # to use for the Date header of the email.
94 ('date-header-order', 'modified, issued, created, expired'),
95 # Set this to add bonus headers to all emails
96 # Example: bonus-header = 'Approved: joe@bob.org'
98 # True: Receive one email per post.
99 # False: Receive an email every time a post changes.
100 ('trust-guid', str(True)),
101 # To most correctly encode emails with international
102 # characters, we iterate through the list below and use the
103 # first character set that works.
104 ('encodings', 'US-ASCII, ISO-8859-1, UTF-8, BIG5, ISO-2022-JP'),
105 # User processing hooks. Note the space after the module name.
106 # Example: post-process = 'rss2email.post_process.downcase downcase_message'
107 ('post-process', ''),
108 # User processing hooks for digest messages. If 'digest' is
109 # enabled, the usual 'post-process' hook gets to massage the
110 # per-entry messages, but this hook is called with the full
111 # digest message before it is mailed.
112 # Example: digest-post-process = 'rss2email.post_process.downcase downcase_message'
113 ('digest-post-process', ''),
115 # True: Send text/html messages when possible.
116 # False: Convert HTML to plain text.
117 ('html-mail', str(False)),
118 # Optional CSS styling
119 ('use-css', str(False)),
122 ' font: 18pt Georgia, "Times New Roman";\n'
125 ' font: 12pt Arial;\n'
128 ' font: 12pt Arial;\n'
129 ' font-weight: bold;\n'
133 ' font-family: monospace;\n'
136 ' background: #e0ecff;\n'
137 ' border-bottom: solid 4px #c3d9ff;\n'
139 ' margin-top: 0px;\n'
143 ' font-size: 20px;\n'
144 ' text-decoration: none;\n'
147 ' background: #c3d9ff;\n'
148 ' border-top: solid 4px #c3d9ff;\n'
150 ' margin-bottom: 0px;\n'
153 ' border: solid 4px #c3d9ff;\n'
156 ' margin-left: 5px;\n'
157 ' margin-right: 5px;\n'
160 # Use Unicode characters instead of their ascii psuedo-replacements
161 ('unicode-snob', str(False)),
162 # Put the links after each paragraph instead of at the end.
163 ('links-after-each-paragraph', str(False)),
164 # Wrap long lines at position. 0 for no wrapping.
165 ('body-width', str(0)),
168 # True: Use SMTP_SERVER to send mail.
169 # False: Use sendmail (or compatible) to send mail.
170 ('use-smtp', str(False)),
171 ('sendmail', '/usr/sbin/sendmail'), # Path to sendmail (or compatible)
172 ('smtp-server', 'smtp.yourisp.net:25'), ('smtp-auth', str(False)), # set to True to use SMTP AUTH
173 ('smtp-username', 'username'), # username for SMTP AUTH
174 ('smtp-password', 'password'), # password for SMTP AUTH
175 ('smtp-ssl', str(False)), # Connect to the SMTP server using SSL
178 # Verbosity (one of 'error', 'warning', 'info', or 'debug').
179 ('verbose', 'warning'),