from __future__ import print_function
+import json as json_lib
from tweepy.models import ModelFactory
-from tweepy.utils import import_simplejson
from tweepy.error import TweepError
payload_format = 'json'
- def __init__(self):
- self.json_lib = import_simplejson()
-
def parse(self, method, payload):
try:
- json = self.json_lib.loads(payload)
+ json = json_lib.loads(payload)
except Exception as e:
raise TweepError('Failed to parse JSON payload: %s' % e)
return json
def parse_error(self, payload):
- error_object = self.json_lib.loads(payload)
+ error_object = json_lib.loads(payload)
if 'error' in error_object:
reason = error_object['error']
import re
import requests
import sys
+import json
from requests.exceptions import Timeout
from threading import Thread
from time import sleep
from tweepy.api import API
from tweepy.error import TweepError
-from tweepy.utils import import_simplejson
-json = import_simplejson()
-
STREAM_VERSION = '1.1'
def parse_html_value(html):
-
return html[html.find('>')+1:html.rfind('<')]
def parse_a_href(atag):
-
start = atag.find('"') + 1
end = atag.find('"', start)
return atag[start:end]
return arg
-def import_simplejson():
- try:
- import simplejson as json
- except ImportError:
- try:
- import json # Python 2.6+
- except ImportError:
- try:
- # Google App Engine
- from django.utils import simplejson as json
- except ImportError:
- raise ImportError("Can't load a json library")
-
- return json
-
-
def list_to_csv(item_list):
if item_list:
return ','.join([str(i) for i in item_list])