changeset 16:45000ce6033c

Reading the RSS text, by option
author Walter Cruz <walter@waltercruz.com>
date Tue, 05 Aug 2008 15:18:39 -0300
parents e77fabae9ed8
children ad16b90dae70
files feed2twitter/feed2twitter.egg-info/PKG-INFO feed2twitter/feed2twitter/__init__.py feed2twitter/setup.py
diffstat 3 files changed, 20 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/feed2twitter/feed2twitter.egg-info/PKG-INFO	Tue Aug 05 14:47:31 2008 -0300
+++ b/feed2twitter/feed2twitter.egg-info/PKG-INFO	Tue Aug 05 15:18:39 2008 -0300
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: feed2twitter
-Version: 0.1.6
+Version: 0.1.7dev
 Summary: Publish your feed items to twitter
 Home-page: http://www.assembla.com/spaces/feed2twitter
 Author: Walter Cruz
--- a/feed2twitter/feed2twitter/__init__.py	Tue Aug 05 14:47:31 2008 -0300
+++ b/feed2twitter/feed2twitter/__init__.py	Tue Aug 05 15:18:39 2008 -0300
@@ -17,6 +17,7 @@
 import feedparser, pickle, os, sys, twitter, urllib
 from ConfigParser import ConfigParser, NoOptionError
 import readrss
+import re
 import time
 from pprint import pprint
 from tinyurl import tiny
@@ -30,15 +31,29 @@
         self.username=username
         self.passwd=passwd
         self.twApi=twitter.Api(username=self.username, password=self.passwd)
+        self.set_attr_headers()
         self.rss = readrss.parse(url)
+    
+    def set_attr_headers(self):
+        return
+        self.api.SetUserAgent('"feed2twitter/0.2"')
+    
+
+    def strip_tags(self,value):
+        "Return the given HTML with all tags stripped."
+        txt = re.sub(r'<[^>]*?>', '', value.replace('\t','').replace('\n','')) 
+        return txt.replace('(Comments)','')
 
     def twitIt(self, items):
         oldItems=pItems=0
         for it in list(items):
-            if mode == 'title':
+            if self.mode == 'title':
                 txt=it["title"][0:114] +" "+tiny(it["link"])
-            elif mode == 'text':
-                txt = it['text'][0:140]
+            elif self.mode == 'text':
+                try:
+                    txt = self.strip_tags(it.content[0].value)[0:140]
+                except:
+                    txt = self.strip_tags(it.summary)[0:140]
             else:
                 txt = it['title'][0:144] + " " + tiny(it['link'])
             try:
--- a/feed2twitter/setup.py	Tue Aug 05 14:47:31 2008 -0300
+++ b/feed2twitter/setup.py	Tue Aug 05 15:18:39 2008 -0300
@@ -1,7 +1,7 @@
 from setuptools import setup, find_packages
 import sys, os
 
-version = '0.1.7'
+version = '0.2'
 
 setup(name='feed2twitter',
       version=version,