CHANGELOG: Document this branch's atomic saves
[rss2email.git] / rss2email / config.py
index d8dc0731ecd9ee6d9e32a711f0de9287ac0b4740..fb7cd30ea3f49a55d533507341d2d323a4ec5201 100644 (file)
@@ -1,7 +1,9 @@
-# Copyright (C) 2004-2012 Aaron Swartz
+# Copyright (C) 2004-2013 Aaron Swartz
 #                         Brian Lalor
 #                         Dean Jackson
+#                         Dmitry Bogatov <KAction@gnu.org>
 #                         Erik Hetzner
+#                         Etienne Millon <me@emillon.org>
 #                         Joey Hess
 #                         Lindsey Smith <lindsey.smith@gmail.com>
 #                         Marcel Ackermann
@@ -33,15 +35,25 @@ import html2text as _html2text
 
 
 class Config (_configparser.ConfigParser):
-    def __init__(self, **kwargs):
-        super(Config, self).__init__(dict_type=_collections.OrderedDict)
+    def __init__(self, dict_type=_collections.OrderedDict,
+                 interpolation=_configparser.ExtendedInterpolation(),
+                 **kwargs):
+        super(Config, self).__init__(
+            dict_type=dict_type, interpolation=interpolation, **kwargs)
 
-    def _setup(self, section='DEFAULT'):
+    def setup_html2text(self, section='DEFAULT'):
+        """Setup html2text globals to match our configuration
+
+        Html2text unfortunately uses globals (instead of keyword
+        arguments) to configure its conversion.
+        """
+        if section not in self:
+            section = 'DEFAULT'
         _html2text.UNICODE_SNOB = self.getboolean(
-            section, 'unicode-snob', fallback=False)
+            section, 'unicode-snob')
         _html2text.LINKS_EACH_PARAGRAPH = self.getboolean(
-            section, 'links-after-each-paragaph', fallback=False)
-        _html2text.BODY_WIDTH = self.getint(section, 'body-width', fallback=0)
+            section, 'links-after-each-paragraph')
+        _html2text.BODY_WIDTH = self.getint(section, 'body-width')
 
 
 CONFIG = Config()
@@ -51,6 +63,9 @@ CONFIG['DEFAULT'] = _collections.OrderedDict((
         ### Addressing
         # The email address messages are from by default
         ('from', 'user@rss2email.invalid'),
+        # Transfer-Encoding. For local mailing it is safe and
+        # convient to use 8bit.
+        ('use-8bit', str(False)),
         # True: Only use the 'from' address.
         # False: Use the email address specified by the feed, when possible.
         ('force-from', str(False)),
@@ -73,6 +88,9 @@ CONFIG['DEFAULT'] = _collections.OrderedDict((
         # True: Fetch, process, and email feeds.
         # False: Don't fetch, process, or email feeds
         ('active', str(True)),
+        # True: Send a single, multi-entry email per feed per rss2email run.
+        # False: Send a single email per entry.
+        ('digest', str(False)),
         # True: Generate Date header based on item's date, when possible.
         # False: Generate Date header based on time sent.
         ('date-header', str(False)),
@@ -89,9 +107,17 @@ CONFIG['DEFAULT'] = _collections.OrderedDict((
         ('trust-guid', str(True)),
         # To most correctly encode emails with international
         # characters, we iterate through the list below and use the
-        # first character set that works Eventually (and
-        # theoretically) UTF-8 is our catch-all failsafe.
-        ('encodings', 'US-ASCII, BIG5, ISO-2022-JP, ISO-8859-1, UTF-8'),
+        # 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.post_process.downcase downcase_message'
+        ('post-process', ''),
+        # User processing hooks for digest messages.  If 'digest' is
+        # enabled, the usual 'post-process' hook gets to massage the
+        # per-entry messages, but this hook is called with the full
+        # digest message before it is mailed.
+        # Example: digest-post-process = 'rss2email.post_process.downcase downcase_message'
+        ('digest-post-process', ''),
         ## HTML conversion
         # True: Send text/html messages when possible.
         # False: Convert HTML to plain text.
@@ -146,13 +172,25 @@ CONFIG['DEFAULT'] = _collections.OrderedDict((
         ('body-width', str(0)),
 
         ### Mailing
+        # Select protocol from: sendmail, smtp, imap
+        ('email-protocol', 'sendmail'),
         # True: Use SMTP_SERVER to send mail.
-        # False: Call /usr/sbin/sendmail to send mail.
-        ('use-smtp', str(False)),
-        ('smtp-server', 'smtp.yourisp.net:25'),        ('smtp-auth', str(False)),      # set to True to use SMTP AUTH
+        # Sendmail (or compatible) configuration
+        ('sendmail', '/usr/sbin/sendmail'),  # Path to sendmail (or compatible)
+        # SMTP configuration
+        ('smtp-auth', str(False)),      # set to True to use SMTP AUTH
         ('smtp-username', 'username'),  # username for SMTP AUTH
         ('smtp-password', 'password'),  # password for SMTP AUTH
+        ('smtp-server', 'smtp.yourisp.net:25'),
         ('smtp-ssl', str(False)),       # Connect to the SMTP server using SSL
+        # IMAP configuration
+        ('imap-auth', str(False)),      # set to True to use IMAP auth.
+        ('imap-username', 'username'),  # username for IMAP authentication
+        ('imap-password', 'password'),  # password for IMAP authentication
+        ('imap-server', 'imap.yourisp.net'),
+        ('imap-port', str(143)),
+        ('imap-ssl', str(False)),       # connect to the IMAP server using SSL
+        ('imap-mailbox', 'INBOX'),      # where we should store new messages
 
         ### Miscellaneous
         # Verbosity (one of 'error', 'warning', 'info', or 'debug').