]> git.sommitrealweird.co.uk Git - rss2maildir.git/commitdiff
* fix README to have a more complete config example
authorBrett Parker <iDunno@sommitrealweird.co.uk>
Sat, 5 Jan 2008 17:00:57 +0000 (17:00 +0000)
committerBrett Parker <iDunno@sommitrealweird.co.uk>
Sat, 5 Jan 2008 17:00:57 +0000 (17:00 +0000)
* stop text width from being hardcoded

README
rss2maildir.py

diff --git a/README b/README
index f151bc9e0c6349b26d84189311823bd958d5dd46..3c45647370f044384705bbae46c7ace0a7463a26 100644 (file)
--- a/README
+++ b/README
@@ -1,5 +1,5 @@
 rss2maildir
 rss2maildir
-=========
+===========
 
 Introduction
 ------------
 
 Introduction
 ------------
@@ -13,3 +13,17 @@ Usage
 
 Create a config file containing the feeds and their "names" - the names will be
 used as the directory name of the maildir for the feed.
 
 Create a config file containing the feeds and their "names" - the names will be
 used as the directory name of the maildir for the feed.
+
+Config File Format
+------------------
+
+  [general]
+  state_dir = "/path/to/a/writtable/directory/to/write/state/to"
+  maildir_root = "/path/to/directory/to/write/maildirs/in"
+
+  [http://path/to/a/rss/feed/]
+  maildir = "name of folder to put mail in"
+
+The state_dir in the general section defaults to the current working directory + state.
+The maildir_root defaults to the current working directory + "RSSMaildir".
+
index a0c40a1513e064b56166bab45e2cc294db3164e1..322dc5751d2f77efe51f301b5dba9a4b2799381b 100755 (executable)
@@ -58,7 +58,7 @@ class HTML2Text(HTMLParser):
         "nbsp": " ",
         }
 
         "nbsp": " ",
         }
 
-    def __init__(self):
+    def __init__(self,textwidth=70):
         self.inheadingone = False
         self.inheadingtwo = False
         self.inotherheading = False
         self.inheadingone = False
         self.inheadingtwo = False
         self.inotherheading = False
@@ -73,6 +73,7 @@ class HTML2Text(HTMLParser):
         self.inul = False
         self.initem = False
         self.item = u''
         self.inul = False
         self.initem = False
         self.item = u''
+        self.textwidth = textwidth
         HTMLParser.__init__(self)
 
     def handle_starttag(self, tag, attrs):
         HTMLParser.__init__(self)
 
     def handle_starttag(self, tag, attrs):
@@ -97,7 +98,7 @@ class HTML2Text(HTMLParser):
                 self.text = self.text + u'\n\n'
             if self.inparagraph:
                 self.text = self.text \
                 self.text = self.text + u'\n\n'
             if self.inparagraph:
                 self.text = self.text \
-                    + u'\n'.join(textwrap.wrap(self.currentparagraph, 70))
+                    + u'\n'.join(textwrap.wrap(self.currentparagraph, self.textwidth))
             self.currentparagraph = u''
             self.inparagraph = True
         elif tag.lower() == "pre":
             self.currentparagraph = u''
             self.inparagraph = True
         elif tag.lower() == "pre":
@@ -117,7 +118,7 @@ class HTML2Text(HTMLParser):
                 self.text = self.text \
                     + u' * ' \
                     + u'\n   '.join([a.strip() for a in \
                 self.text = self.text \
                     + u' * ' \
                     + u'\n   '.join([a.strip() for a in \
-                        textwrap.wrap(self.item, 67)]) \
+                        textwrap.wrap(self.item, self.textwidth - 3)]) \
                     + u'\n'
                 self.item = u''
                 self.initem = True
                     + u'\n'
                 self.item = u''
                 self.initem = True
@@ -132,7 +133,7 @@ class HTML2Text(HTMLParser):
                 + u'\n'.join( \
                     [a \
                         for a in textwrap.wrap( \
                 + u'\n'.join( \
                     [a \
                         for a in textwrap.wrap( \
-                            self.currentparagraph, 70) \
+                            self.currentparagraph, self.textwidth) \
                     ] \
                 ) \
                 + u'\n'
                     ] \
                 ) \
                 + u'\n'
@@ -180,7 +181,7 @@ class HTML2Text(HTMLParser):
         elif tag.lower() == "p":
             self.text = self.text \
                 + u'\n'.join(textwrap.wrap( \
         elif tag.lower() == "p":
             self.text = self.text \
                 + u'\n'.join(textwrap.wrap( \
-                    self.currentparagraph, 70) \
+                    self.currentparagraph, self.textwidth) \
                 )
             self.inparagraph = False
             self.currentparagraph = u''
                 )
             self.inparagraph = False
             self.currentparagraph = u''
@@ -190,7 +191,7 @@ class HTML2Text(HTMLParser):
                 + u'\n> '.join( \
                     [a.strip() \
                         for a in textwrap.wrap( \
                 + u'\n> '.join( \
                     [a.strip() \
                         for a in textwrap.wrap( \
-                            self.blockquote, 68)] \
+                            self.blockquote, self.textwidth - 2)] \
                     ) \
                 + u'\n'
             self.inblockquote = False
                     ) \
                 + u'\n'
             self.inblockquote = False
@@ -203,7 +204,7 @@ class HTML2Text(HTMLParser):
                 self.text = self.text \
                     + u' * ' \
                     + u'\n   '.join( \
                 self.text = self.text \
                     + u' * ' \
                     + u'\n   '.join( \
-                        [a.strip() for a in textwrap.wrap(self.item, 67)]) \
+                        [a.strip() for a in textwrap.wrap(self.item, self.textwidth - 3)]) \
                     + u'\n'
             self.item = u''
         elif tag.lower() == "ul":
                     + u'\n'
             self.item = u''
         elif tag.lower() == "ul":
@@ -251,7 +252,7 @@ class HTML2Text(HTMLParser):
     def gettext(self):
         data = self.text
         if self.inparagraph:
     def gettext(self):
         data = self.text
         if self.inparagraph:
-            data = data + "\n".join(textwrap.wrap(self.currentparagraph, 70))
+            data = data + "\n".join(textwrap.wrap(self.currentparagraph, self.textwidth))
         if data[-1] != '\n':
             data = data + '\n'
         return data
         if data[-1] != '\n':
             data = data + '\n'
         return data