New package structure; twython is now separated out into core/oauth/streaming. To maintain compatibility with older Twython versions, simply import twython like: 'import twython.core as twython' - this will allow for easier oauth/streaming development, and should hopefully fix a lot of the installation issues people kept running into with easy_install

This commit is contained in:
Ryan McGrath 2009-12-17 03:05:39 -05:00
parent fc5aaebda3
commit a3edbb2348
26 changed files with 35 additions and 34 deletions

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
*.pyc
build
dist
twython.egg-info

View file

@ -1 +0,0 @@
import twython as twython

View file

@ -1,4 +1,4 @@
import twitter import twython.core as twython
""" Instantiate Twython with no Authentication """ """ Instantiate Twython with no Authentication """
twitter = twython.setup() twitter = twython.setup()

View file

@ -1,4 +1,4 @@
import twitter import twython.core as twython
""" Instantiate Twython with no Authentication """ """ Instantiate Twython with no Authentication """
twitter = twython.setup() twitter = twython.setup()

View file

@ -1,7 +1,7 @@
import twython, pprint import twython.core as twython, pprint
# Authenticate using Basic (HTTP) Authentication # Authenticate using Basic (HTTP) Authentication
twitter = twython.setup(authtype="Basic", username="example", password="example") twitter = twython.setup(username="example", password="example")
friends_timeline = twitter.getFriendsTimeline(count="150", page="3") friends_timeline = twitter.getFriendsTimeline(count="150", page="3")
for tweet in friends_timeline: for tweet in friends_timeline:

View file

@ -1,6 +1,6 @@
import twitter import twython.core as twython
twitter = twython.setup(authtype="Basic", username="example", password="example") twitter = twython.setup(username="example", password="example")
mentions = twitter.getUserMentions(count="150") mentions = twitter.getUserMentions(count="150")
print mentions print mentions

View file

@ -1,4 +1,4 @@
import twython import twython.core as twython
# We won't authenticate for this, but sometimes it's necessary # We won't authenticate for this, but sometimes it's necessary
twitter = twython.setup() twitter = twython.setup()

View file

@ -1,4 +1,4 @@
import twython import twython.core as twython
# Getting the public timeline requires no authentication, huzzah # Getting the public timeline requires no authentication, huzzah
twitter = twython.setup() twitter = twython.setup()

View file

@ -1,7 +1,7 @@
import twython import twython.core as twython
# Instantiate with Basic (HTTP) Authentication # Instantiate with Basic (HTTP) Authentication
twitter = twython.setup(authtype="Basic", username="example", password="example") twitter = twython.setup(username="example", password="example")
# This returns the rate limit for the requesting IP # This returns the rate limit for the requesting IP
rateLimit = twitter.getRateLimitStatus() rateLimit = twitter.getRateLimitStatus()

View file

@ -1,4 +1,4 @@
import twython import twython.core as twython
""" Instantiate Tango with no Authentication """ """ Instantiate Tango with no Authentication """
twitter = twython.setup() twitter = twython.setup()

View file

@ -1,4 +1,4 @@
import twython import twython as twython
# Shortening URLs requires no authentication, huzzah # Shortening URLs requires no authentication, huzzah
twitter = twython.setup() twitter = twython.setup()

View file

@ -1,11 +1,7 @@
import twython import twython.core as twython
# Using no authentication and specifying Debug # Using no authentication
twitter = twython.setup(debug=True) twitter = twython.setup()
# Using Basic Authentication # Using Basic Authentication (core is all about basic auth, look to twython.oauth in the future for oauth)
twitter = twython.setup(authtype="Basic", username="example", password="example") twitter = twython.setup(username="example", password="example")
# Using OAuth Authentication (Note: OAuth is the default, specify Basic if needed)
auth_keys = {"consumer_key": "yourconsumerkey", "consumer_secret": "yourconsumersecret"}
twitter = twython.setup(username="example", password="example", oauth_keys=auth_keys)

View file

@ -1,5 +1,5 @@
import twython import twython.core as twython
# Instantiate Twython with Basic (HTTP) Authentication # Instantiate Twython with Basic (HTTP) Authentication
twitter = twython.setup(authtype="Basic", username="example", password="example") twitter = twython.setup(username="example", password="example")
twitter.updateProfileImage("myImage.png") twitter.updateProfileImage("myImage.png")

View file

@ -1,5 +1,5 @@
import twython import twython.core as twython
# Create a Twython instance using Basic (HTTP) Authentication and update our Status # Create a Twython instance using Basic (HTTP) Authentication and update our Status
twitter = twython.setup(authtype="Basic", username="example", password="example") twitter = twython.setup(username="example", password="example")
twitter.updateStatus("See how easy this was?") twitter.updateStatus("See how easy this was?")

View file

@ -1,4 +1,4 @@
import twython import twython.core as twython
""" Instantiate Twython with no Authentication """ """ Instantiate Twython with no Authentication """
twitter = twython.setup() twitter = twython.setup()

View file

@ -3,9 +3,7 @@
import sys, os import sys, os
__author__ = 'Ryan McGrath <ryan@venodesigns.net>' __author__ = 'Ryan McGrath <ryan@venodesigns.net>'
__version__ = '0.9' __version__ = '1.0'
# For the love of god, use Pip to install this.
# Distutils version # Distutils version
METADATA = dict( METADATA = dict(

1
twython/__init__.py Normal file
View file

@ -0,0 +1 @@
import core, oauth, streaming

View file

@ -16,7 +16,7 @@ from urlparse import urlparse
from urllib2 import HTTPError from urllib2 import HTTPError
__author__ = "Ryan McGrath <ryan@venodesigns.net>" __author__ = "Ryan McGrath <ryan@venodesigns.net>"
__version__ = "0.9" __version__ = "1.0"
"""Twython - Easy Twitter utilities in Python""" """Twython - Easy Twitter utilities in Python"""

View file

@ -7,17 +7,17 @@
Questions, comments? ryan@venodesigns.net Questions, comments? ryan@venodesigns.net
""" """
import twython, httplib, urllib, urllib2, mimetypes, mimetools import httplib, urllib, urllib2, mimetypes, mimetools
from urlparse import urlparse from urlparse import urlparse
from urllib2 import HTTPError from urllib2 import HTTPError
try: try:
import oauth import oauth as oauthlib
except ImportError: except ImportError:
pass pass
class twyauth: class oauth:
def __init__(self, username, consumer_key, consumer_secret, signature_method = None, headers = None, version = 1): def __init__(self, username, consumer_key, consumer_secret, signature_method = None, headers = None, version = 1):
"""oauth(username = None, consumer_secret = None, consumer_key = None, headers = None) """oauth(username = None, consumer_secret = None, consumer_key = None, headers = None)

BIN
twython/oauth/__init__.pyc Normal file

Binary file not shown.

BIN
twython/oauth/oauth.pyc Normal file

Binary file not shown.

View file

@ -1,6 +1,8 @@
#!/usr/bin/python #!/usr/bin/python
""" """
Yes, this is just in __init__ for now, hush.
The beginnings of Twitter Streaming API support in Twython. Don't expect this to work at all, The beginnings of Twitter Streaming API support in Twython. Don't expect this to work at all,
consider it a stub for now. -- Ryan consider it a stub for now. -- Ryan

Binary file not shown.

1
twython3k/__init__.py Normal file
View file

@ -0,0 +1 @@
import core