Moved some code around.
authorJosh Roesslein <jroesslein@gmail.com>
Sun, 5 Jul 2009 19:33:01 +0000 (14:33 -0500)
committerJosh Roesslein <jroesslein@gmail.com>
Sun, 5 Jul 2009 19:33:01 +0000 (14:33 -0500)
api.py
parsers.py [new file with mode: 0644]

diff --git a/api.py b/api.py
index ae0a15d92df24c69a639c5e02ca7f508c1f2d6e8..163c7408444fa4280b007ccabbf36bf170d1e4ec 100644 (file)
--- 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 (file)
index 0000000..0d5cad4
--- /dev/null
@@ -0,0 +1,8 @@
+try:
+  import json
+except ImportError:
+  import simplejson as json
+
+def parse_error(jsondata):
+
+  return json.loads(jsondata)['error']