Name change, inserting a basic docstring to get the ball rolling
This commit is contained in:
parent
0101d3b3e4
commit
0d086c5395
1 changed files with 23 additions and 5 deletions
|
|
@ -1,7 +1,9 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Tango is an up-to-date library for Python that wraps the Twitter API.
|
NOTE: Tango is being renamed to Twython; all basic strings have been changed below, but there's still work ongoing in this department.
|
||||||
|
|
||||||
|
Twython is an up-to-date library for Python that wraps the Twitter API.
|
||||||
Other Python Twitter libraries seem to have fallen a bit behind, and
|
Other Python Twitter libraries seem to have fallen a bit behind, and
|
||||||
Twitter's API has evolved a bit. Here's hoping this helps.
|
Twitter's API has evolved a bit. Here's hoping this helps.
|
||||||
|
|
||||||
|
|
@ -15,7 +17,9 @@ import httplib, urllib, urllib2, mimetypes, mimetools
|
||||||
from urllib2 import HTTPError
|
from urllib2 import HTTPError
|
||||||
|
|
||||||
__author__ = "Ryan McGrath <ryan@venodesigns.net>"
|
__author__ = "Ryan McGrath <ryan@venodesigns.net>"
|
||||||
__version__ = "0.6"
|
__version__ = "0.8.0.1"
|
||||||
|
|
||||||
|
"""Twython - Easy Twitter utilities in Python"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import simplejson
|
import simplejson
|
||||||
|
|
@ -23,7 +27,7 @@ except ImportError:
|
||||||
try:
|
try:
|
||||||
import json as simplejson
|
import json as simplejson
|
||||||
except:
|
except:
|
||||||
raise Exception("Tango requires the simplejson library (or Python 2.6) to work. http://www.undefined.org/python/")
|
raise Exception("Twython requires the simplejson library (or Python 2.6) to work. http://www.undefined.org/python/")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import oauth
|
import oauth
|
||||||
|
|
@ -86,13 +90,27 @@ class setup:
|
||||||
|
|
||||||
# URL Shortening function huzzah
|
# URL Shortening function huzzah
|
||||||
def shortenURL(self, url_to_shorten, shortener = "http://is.gd/api.php", query = "longurl"):
|
def shortenURL(self, url_to_shorten, shortener = "http://is.gd/api.php", query = "longurl"):
|
||||||
try:
|
"""
|
||||||
|
function:: shortenURL(url_to_shorten, shortener, query)
|
||||||
|
|
||||||
|
Returns a shortened URL.
|
||||||
|
|
||||||
|
:param url_to_shorten: URL to shorten, as a String
|
||||||
|
:param shortener: URL to an API call for a different shortening service, allows overriding.
|
||||||
|
:param query: Name of the param that you pass the long URL as.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
>>> twitter = tango.setup()
|
||||||
|
>>> twitter.shortenURL("http://webs.com/")
|
||||||
|
|
||||||
|
"""
|
||||||
|
try:
|
||||||
return urllib2.urlopen(shortener + "?" + urllib.urlencode({query: url_to_shorten})).read()
|
return urllib2.urlopen(shortener + "?" + urllib.urlencode({query: url_to_shorten})).read()
|
||||||
except HTTPError, e:
|
except HTTPError, e:
|
||||||
raise TangoError("shortenURL() failed with a %s error code." % `e.code`)
|
raise TangoError("shortenURL() failed with a %s error code." % `e.code`)
|
||||||
|
|
||||||
def constructApiURL(self, base_url, params):
|
def constructApiURL(self, base_url, params):
|
||||||
return base_url + "?" + "&".join(["%s=%s" %(key, value) for (key, value) in params.iteritems()])
|
return base_url + "?" + "&".join(["%s=%s" %(key, value) for (key, value) in params.iteritems()])
|
||||||
|
|
||||||
def getRateLimitStatus(self, rate_for = "requestingIP"):
|
def getRateLimitStatus(self, rate_for = "requestingIP"):
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue