From 7bbbf62a5fd5da4cebb398e1c8d04645bdeceae2 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 4 Oct 2012 08:40:02 -0400 Subject: [PATCH] Setup html2text in Config._setup(). --- rss2email.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/rss2email.py b/rss2email.py index 3919bd7..a18aec6 100755 --- a/rss2email.py +++ b/rss2email.py @@ -71,6 +71,12 @@ class Config (_configparser.ConfigParser): def __init__(self, **kwargs): super(Config, self).__init__(dict_type=_collections.OrderedDict) + def _setup(self, section='DEFAULT'): + _html2text.UNICODE_SNOB = self.getboolean( + section, 'unicode-snob', fallback=False) + _html2text.LINKS_EACH_PARAGRAPH = self.getboolean( + section, 'links-after-each-paragaph', fallback=False) + _html2text.BODY_WIDTH = self.getint(section, 'body-width', fallback=0) CONFIG = Config() @@ -168,9 +174,9 @@ CONFIG['DEFAULT'] = _collections.OrderedDict(( '}\n')), ## html2text options # Use Unicode characters instead of their ascii psuedo-replacements - ('unicode-snob': str(False)), + ('unicode-snob', str(False)), # Put the links after each paragraph instead of at the end. - ('link-after-each-paragraph', str(False)), + ('links-after-each-paragraph', str(False)), # Wrap long lines at position. 0 for no wrapping. ('body-width', str(0)), @@ -332,11 +338,6 @@ for e in ['error', 'gaierror']: feedparser.USER_AGENT = "rss2email/"+__version__+ " +http://www.allthingsrss.com/rss2email/" -h2t.UNICODE_SNOB = UNICODE_SNOB -h2t.LINKS_EACH_PARAGRAPH = LINKS_EACH_PARAGRAPH -h2t.BODY_WIDTH = BODY_WIDTH -html2text = h2t.html2text - ### Utility Functions ### class TimeoutError(Exception): pass -- 2.26.2