Python Twitter Tools
-The Minimalist Twitter API for Python is a Python API for Twitter, everyone's favorite Web 2.0 Facebook-style status updater for people on the go.
+The Minimalist Twitter API for Python is a Python API for Twitter,
+everyone's favorite Web 2.0 Facebook-style status updater for people
+on the go.
-Also included is a twitter command-line tool for getting your friends' tweets and setting your own tweet from the safety and security of your favorite shell and an IRC bot that can announce Twitter updated to an IRC channel.
+Also included is a twitter command-line tool for getting your friends'
+tweets and setting your own tweet from the safety and security of your
+favorite shell and an IRC bot that can announce Twitter updated to an
+IRC channel.
For more information:
from setuptools import setup, find_packages
import sys, os
-version = '0.4'
+version = '0.4.1'
setup(name='twitter',
version=version,
from exceptions import Exception
+def _py26OrGreater():
+ import sys
+ return sys.hexversion > 0x20600f0
+
+if _py26OrGreater():
+ import json
+else:
+ import simplejson as json
+
class TwitterError(Exception):
"""
Exception thrown by the Twitter object when there is an
raise TwitterError("Twitter sent status %i: %s" %(
r.status, r.read()))
if ("json" == self.format):
- import simplejson
- return simplejson.loads(r.read())
+ return json.loads(r.read())
else:
return r.read()
finally:
"""
if (format not in ("json", "xml")):
raise TwitterError("Unknown data format '%s'" %(format))
- if (format == "json"):
- try:
- import simplejson
- except ImportError:
- raise TwitterError(
- "format not available: simplejson is not installed")
TwitterCall.__init__(self, email, password, format)
__all__ = ["Twitter"]
else:
doAction()
except TwitterError, e:
- print >> sys.stderr, e.message
+ print >> sys.stderr, e.args[0]
print >> sys.stderr, "Use 'twitter -h' for help."
sys.exit(1)
except KeyboardInterrupt: