+ Moved documentation out of api.py and into wiki.
+ Removed 'email' parameter from API.update_profile. No longer supported.
+ API.auth_handler -> API.auth
++ Moved memcache implementation to tweepy-more repository.
1.1 -> 1.2 [Current]
=====================
+ Up-to-date with Twitter API
+ Actively under development
+ Streaming API support
- + Cache system (memory, file, memcache)
+ + Cache system (memory, file)
+ Python 3 branch (3.1)
Getting started:
Souce code:
Library: http://github.com/joshthecoder/tweepy
Examples: http://github.com/joshthecoder/tweepy-examples
+ Extensions: http://github.com/joshthecoder/tweepy-more
Author: Joshua Roesslein
License: MIT
**Included in python 2.6+
Python-OAuth <http://code.google.com/p/oauth>
**Bundled with this library
- python-memcached <http://www.tummy.com/Community/software/python-memcached/>
- **Bundled with this library
self.cache.flush()
os.rmdir('cache_test_dir')
- def testmemcache(self):
- self.cache = MemCache(self.memcache_servers, self.timeout)
- self._run_tests(do_cleanup=False)
if __name__ == '__main__':
from tweepy.models import Status, User, DirectMessage, Friendship, SavedSearch, SearchResult, models
from tweepy.error import TweepError
from tweepy.api import API
-from tweepy.cache import Cache, MemoryCache, FileCache, MemCache
+from tweepy.cache import Cache, MemoryCache, FileCache
from tweepy.auth import BasicAuthHandler, OAuthHandler
from tweepy.streaming import Stream, StreamListener
from tweepy.cursor import Cursor
# TODO: use win32file
pass
-from tweepy import memcache
-
class Cache(object):
"""Cache interface"""
continue
self._delete_file(os.path.join(self.cache_dir, entry))
-
-class MemCache(Cache):
- """Memcache client"""
-
- def __init__(self, servers, timeout=60):
- Cache.__init__(self, timeout)
- self.client = memcache.Client(servers)
-
- def store(self, key, value):
- self.client.set(key, (time.time(), value), time=self.timeout)
-
- def get(self, key, timeout=None):
- obj = self.client.get(key)
- if obj is None:
- return None
- created_time, value = obj
-
- # check if value is expired
- if timeout is None:
- timeout = self.timeout
- if timeout > 0 and (time.time() - created_time) >= timeout:
- # expired! delete from cache
- self.client.delete(key)
- return None
-
- return value
-
- def count(self):
- count = 0
- for sid, stats in self.client.get_stats():
- count += int(stats.get('curr_items', 0))
- return count
-
- def cleanup(self):
- # not implemented for this cache since server handles it
- return
-
- def flush(self):
- self.client.flush_all()
-