changeset 15:e77fabae9ed8

Adding mode setting: title or text
author Walter Cruz <walter@waltercruz.com>
date Tue, 05 Aug 2008 14:47:31 -0300
parents 5a635718793a
children 45000ce6033c
files feed2twitter/feed2twitter.egg-info/PKG-INFO feed2twitter/feed2twitter/__init__.py feed2twitter/setup.py
diffstat 3 files changed, 17 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/feed2twitter/feed2twitter.egg-info/PKG-INFO	Tue Jul 15 16:14:21 2008 -0300
+++ b/feed2twitter/feed2twitter.egg-info/PKG-INFO	Tue Aug 05 14:47:31 2008 -0300
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: feed2twitter
-Version: 0.1.3
+Version: 0.1.6
 Summary: Publish your feed items to twitter
 Home-page: http://www.assembla.com/spaces/feed2twitter
 Author: Walter Cruz
--- a/feed2twitter/feed2twitter/__init__.py	Tue Jul 15 16:14:21 2008 -0300
+++ b/feed2twitter/feed2twitter/__init__.py	Tue Aug 05 14:47:31 2008 -0300
@@ -24,17 +24,23 @@
 from urllib2 import HTTPError
 
 class Feed2Twitter(object):
-    def __init__(self,  url, username, passwd):
-      self.url=url
-      self.username=username
-      self.passwd=passwd
-      self.twApi=twitter.Api(username=self.username, password=self.passwd)
-      self.rss = readrss.parse(url)
+    def __init__(self,  url, username, passwd, mode='title'):
+        self.mode = mode
+        self.url=url
+        self.username=username
+        self.passwd=passwd
+        self.twApi=twitter.Api(username=self.username, password=self.passwd)
+        self.rss = readrss.parse(url)
 
     def twitIt(self, items):
         oldItems=pItems=0
         for it in list(items):
-            txt=it["title"][0:114] +" "+tiny(it["link"])
+            if mode == 'title':
+                txt=it["title"][0:114] +" "+tiny(it["link"])
+            elif mode == 'text':
+                txt = it['text'][0:140]
+            else:
+                txt = it['title'][0:144] + " " + tiny(it['link'])
             try:
                 status = self.twApi.PostUpdate(txt)
                 self.rss.updateLastRead(it)
@@ -66,7 +72,8 @@
     url = c.get("global", "url").strip()
     username = c.get("global", "username").strip()
     password = c.get("global", "password").strip()
+    mode = c.get("global","mode").strip()
 
 
-    feed2tw = Feed2Twitter(url,username,password)
+    feed2tw = Feed2Twitter(url, username, password, mode)
     feed2tw.update()
--- a/feed2twitter/setup.py	Tue Jul 15 16:14:21 2008 -0300
+++ b/feed2twitter/setup.py	Tue Aug 05 14:47:31 2008 -0300
@@ -1,7 +1,7 @@
 from setuptools import setup, find_packages
 import sys, os
 
-version = '0.1.6'
+version = '0.1.7'
 
 setup(name='feed2twitter',
       version=version,