From 1cd325d4a5426232d7d08312e5210c06edab1342 Mon Sep 17 00:00:00 2001 From: Josh Roesslein Date: Sun, 5 Jul 2009 14:33:01 -0500 Subject: [PATCH] Moved some code around. --- api.py | 10 +++------- parsers.py | 8 ++++++++ 2 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 parsers.py diff --git a/api.py b/api.py index ae0a15d..163c740 100644 --- a/api.py +++ b/api.py @@ -1,13 +1,9 @@ import urllib import urllib2 -try: - import json -except ImportError: - import simplejson as json - from misc import * from models import * +from parsers import * """ Twitter API Interface @@ -34,7 +30,7 @@ class API(object): self._opener = self._build_opener(username, password) def public_timeline(self): - return self._fetch('statuses/public_timelinee.json') + return self._fetch('statuses/public_timelinee.json') @require_auth def friends_timeline(self, since_id=None, max_id=None, count=None, page=None): @@ -67,4 +63,4 @@ class API(object): try: return self._opener.open(req) except urllib2.HTTPError, e: - raise TweepError(json.loads(e.read())['error']) + raise TweepError(parse_error(e.read())) diff --git a/parsers.py b/parsers.py new file mode 100644 index 0000000..0d5cad4 --- /dev/null +++ b/parsers.py @@ -0,0 +1,8 @@ +try: + import json +except ImportError: + import simplejson as json + +def parse_error(jsondata): + + return json.loads(jsondata)['error'] -- 2.25.1