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_html2text(self, section='DEFAULT'):
45 """Setup html2text globals to match our configuration
47 Html2text unfortunately uses globals (instead of keyword
48 arguments) to configure its conversion.
50 if section not in self:
52 _html2text.UNICODE_SNOB = self.getboolean(
53 section, 'unicode-snob')
54 _html2text.LINKS_EACH_PARAGRAPH = self.getboolean(
55 section, 'links-after-each-paragraph')
56 _html2text.BODY_WIDTH = self.getint(section, 'body-width')
61 # setup defaults for feeds that don't customize
62 CONFIG['DEFAULT'] = _collections.OrderedDict((
64 # The email address messages are from by default
65 ('from', 'user@rss2email.invalid'),
66 # Transfer-Encoding. For local mailing it is safe and
67 # convient to use 8bit.
68 ('use-8bit', str(False)),
69 # True: Only use the 'from' address.
70 # False: Use the email address specified by the feed, when possible.
71 ('force-from', str(False)),
72 # True: Use the publisher's email if you can't find the author's.
73 # False: Just use the 'from' email instead.
74 ('use-publisher-email', str(False)),
75 # Only use the feed email address rather than friendly name
77 ('friendly-name', str(True)),
78 # Set this to default To email addresses.
82 # Set an HTTP proxy (e.g. 'http://your.proxy.here:8080/')
84 # Set the timeout (in seconds) for feed server response
85 ('feed-timeout', str(60)),
88 # True: Fetch, process, and email feeds.
89 # False: Don't fetch, process, or email feeds
90 ('active', str(True)),
91 # True: Generate Date header based on item's date, when possible.
92 # False: Generate Date header based on time sent.
93 ('date-header', str(False)),
94 # A comma-delimited list of some combination of
95 # ('issued', 'created', 'modified', 'expired')
96 # expressing ordered list of preference in dates
97 # to use for the Date header of the email.
98 ('date-header-order', 'modified, issued, created, expired'),
99 # Set this to add bonus headers to all emails
100 # Example: bonus-header = 'Approved: joe@bob.org'
101 ('bonus-header', ''),
102 # True: Receive one email per post.
103 # False: Receive an email every time a post changes.
104 ('trust-guid', str(True)),
105 # To most correctly encode emails with international
106 # characters, we iterate through the list below and use the
107 # first character set that works.
108 ('encodings', 'US-ASCII, ISO-8859-1, UTF-8, BIG5, ISO-2022-JP'),
109 # User processing hooks. Note the space after the module name.
110 # Example: post-process = 'rss2email.post_process.downcase downcase_message'
111 ('post-process', ''),
113 # True: Send text/html messages when possible.
114 # False: Convert HTML to plain text.
115 ('html-mail', str(False)),
116 # Optional CSS styling
117 ('use-css', str(False)),
120 ' font: 18pt Georgia, "Times New Roman";\n'
123 ' font: 12pt Arial;\n'
126 ' font: 12pt Arial;\n'
127 ' font-weight: bold;\n'
131 ' font-family: monospace;\n'
134 ' background: #e0ecff;\n'
135 ' border-bottom: solid 4px #c3d9ff;\n'
137 ' margin-top: 0px;\n'
141 ' font-size: 20px;\n'
142 ' text-decoration: none;\n'
145 ' background: #c3d9ff;\n'
146 ' border-top: solid 4px #c3d9ff;\n'
148 ' margin-bottom: 0px;\n'
151 ' border: solid 4px #c3d9ff;\n'
154 ' margin-left: 5px;\n'
155 ' margin-right: 5px;\n'
158 # Use Unicode characters instead of their ascii psuedo-replacements
159 ('unicode-snob', str(False)),
160 # Put the links after each paragraph instead of at the end.
161 ('links-after-each-paragraph', str(False)),
162 # Wrap long lines at position. 0 for no wrapping.
163 ('body-width', str(0)),
166 # Select protocol from: sendmail, smtp, imap
167 ('email-protocol', 'sendmail'),
168 # True: Use SMTP_SERVER to send mail.
169 # Sendmail (or compatible) configuration
170 ('sendmail', '/usr/sbin/sendmail'), # Path to sendmail (or compatible)
172 ('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-server', 'smtp.yourisp.net:25'),
176 ('smtp-ssl', str(False)), # Connect to the SMTP server using SSL
178 ('imap-auth', str(False)), # set to True to use IMAP auth.
179 ('imap-username', 'username'), # username for IMAP authentication
180 ('imap-password', 'password'), # password for IMAP authentication
181 ('imap-server', 'imap.yourisp.net'),
182 ('imap-port', str(143)),
183 ('imap-ssl', str(False)), # connect to the IMAP server using SSL
184 ('imap-mailbox', 'INBOX'), # where we should store new messages
187 # Verbosity (one of 'error', 'warning', 'info', or 'debug').
188 ('verbose', 'warning'),