diff --git a/README b/README index 556f1886..812656af 100644 --- a/README +++ b/README @@ -1,8 +1,13 @@ 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: diff --git a/setup.py b/setup.py index 9a61d640..0e08d6cf 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ from setuptools import setup, find_packages import sys, os -version = '0.4' +version = '0.4.1' setup(name='twitter', version=version, diff --git a/twitter/api.py b/twitter/api.py index c59d121f..41dd277a 100644 --- a/twitter/api.py +++ b/twitter/api.py @@ -6,6 +6,15 @@ 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 @@ -54,8 +63,7 @@ def __call__(self, **kwargs): 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: @@ -120,12 +128,6 @@ def __init__(self, email=None, password=None, format="json"): """ 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"] diff --git a/twitter/cmdline.py b/twitter/cmdline.py index fcf2f6b9..c605e219 100644 --- a/twitter/cmdline.py +++ b/twitter/cmdline.py @@ -191,7 +191,7 @@ def main_with_args(args): 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: