[pytwerp commit] r56 - Added patch from israel.herraiz to allow pyTwerp to work with laconi.ca

2 views
Skip to first unread message

codesite...@google.com

unread,
May 20, 2009, 2:09:48 AM5/20/09
to tw...@googlegroups.com
Author: bear42
Date: Tue May 19 23:09:04 2009
New Revision: 56

Modified:
trunk/CHANGES.txt
trunk/pyTwerp/twerp.py

Log:
Added patch from israel.herraiz to allow pyTwerp to work with laconi.ca
http://code.google.com/p/pytwerp/issues/detail?id=6


Modified: trunk/CHANGES.txt
==============================================================================
--- trunk/CHANGES.txt (original)
+++ trunk/CHANGES.txt Tue May 19 23:09:04 2009
@@ -5,6 +5,9 @@
Bug fix: applied slightly modified patch from gustavodn
http://code.google.com/p/pytwerp/issues/detail?id=7

+ Added patch from israel.herraiz to allow pyTwerp to work with laconi.ca
+ http://code.google.com/p/pytwerp/issues/detail?id=6
+
10 Apr 2009 - bear

Removed all references to --since given that the Twitter folks

Modified: trunk/pyTwerp/twerp.py
==============================================================================
--- trunk/pyTwerp/twerp.py (original)
+++ trunk/pyTwerp/twerp.py Tue May 19 23:09:04 2009
@@ -127,28 +127,28 @@

return result

-def getPublic(since_id=None):
- url = 'http://twitter.com/statuses/public_timeline.json'
+def getPublic(url, since_id=None):
+ url += '/statuses/public_timeline.json'
return fetch(url, mod=since_id)

-def getUser(auth, user, since_id=None):
- url = 'http://twitter.com/statuses/user_timeline/%s.json' % user
+def getUser(auth, user, url, since_id=None):
+ url += '/statuses/user_timeline/%s.json' % user
return fetch(url, auth, mod=since_id)

-def getFriends(auth, user, since_id=None):
- url = 'http://twitter.com/statuses/friends_timeline/%s.json' % user
+def getFriends(auth, user, url, since_id=None):
+ url += '/statuses/friends_timeline/%s.json' % user
return fetch(url, auth, mod=since_id)

-def getReplies(auth, since=None):
- url = 'http://twitter.com/statuses/replies.json'
+def getReplies(auth, url, since_id=None):
+ url += '/statuses/replies.json'
return fetch(url, auth, mod=since_id)

-def postStatus(auth, msg):
- url = 'http://twitter.com/statuses/update.json'
+def postStatus(auth, msg, url):
+ url += '/statuses/update.json'
return fetch(url, auth, post={'status': msg})

-def postDirect(auth, recip, msg):
- url = 'http://twitter.com/direct_messages/new.json'
+def postDirect(auth, recip, msg, url):
+ url += '/direct_messages/new.json'
return fetch(url, auth, post={'user': recip, 'text': msg})

def showMessage(fp):
@@ -194,6 +194,7 @@
op.add_option('-s', '--since', dest='since_id', default=None)
op.add_option('-d', '--direct', dest='direct', default=None)
op.add_option('-t', '--timeline', dest='timeline', default=None)
+ op.add_option('-u', '--url', dest='url', default=None)
op.add_option('-f', '--friends', dest='friends', default=False,
action='store_true')
op.add_option('-r', '--replies', dest='replies', default=False,
action='store_true')
op.add_option('-p', '--public', dest='public', default=False,
action='store_true')
@@ -225,6 +226,14 @@
pass

try:
+ if options.url is None:
+ options.url = cp.get('account', 'url')
+ except ConfigParser.NoOptionError:
+ options.url = 'http://twitter.com'
+
+ options.url = options.url.rstrip('/')
+
+ try:
if options.template is None:
options.template = cp.get('display', 'template')
except ConfigParser.NoOptionError:
@@ -244,6 +253,9 @@
for k, v in last_id.items():
cp.set('last_id', k, v)

+ # always remember last used api url
+ cp.set('account', 'url', options.url)
+
originalMask = os.umask(0077)
try:
cp.write(file(options.confpath, 'w'))
@@ -281,20 +293,25 @@

try:
if options.public:
- doTimeline('_public', getPublic)
+ doTimeline('_public', getPublic, url=options.url)
elif options.replies:
- doTimeline('_replies', getReplies, auth=auth)
+ doTimeline('_replies', getReplies, auth=auth,
+ url=options.url)
elif options.friends:
doTimeline('_friends', getFriends, auth=auth,
- user=options.username)
+ user=options.username,
+ url=options.url)
elif options.timeline:
doTimeline(options.timeline, getUser, auth=auth,
- user=options.timeline)
+ user=options.timeline,
+ url=options.url)
elif options.direct:
doMessage(options.msg, postDirect, auth=auth,
- recip=options.direct)
+ recip=options.direct,
+ url=options.url)
else:
- doMessage(options.msg, postStatus, auth=auth)
+ doMessage(options.msg, postStatus, auth=auth,
+ url=options.url)

if options.save_conf:
saveConfig(options, cp, last_id)

Reply all
Reply to author
Forward
0 new messages