Skip to content

Commit

Permalink
Heading for 0.4.1. Use stdlib json module if available, remove a 2.6 …
Browse files Browse the repository at this point in the history
…deprecation.

git-svn-id: http://svn.mike.verdone.ca/pyprojects/twitter/trunk@181 d723f978-dc38-0410-87ed-da353333cdcc
  • Loading branch information
mverdone committed Oct 3, 2008
1 parent fdbae01 commit f1a8ed6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
9 changes: 7 additions & 2 deletions 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:

Expand Down
2 changes: 1 addition & 1 deletion 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,
Expand Down
18 changes: 10 additions & 8 deletions twitter/api.py
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion twitter/cmdline.py
Expand Up @@ -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:
Expand Down

0 comments on commit f1a8ed6

Please sign in to comment.