Permalink
Browse files

remove simplejson dependency, use cjson everywhere

  • Loading branch information...
1 parent cc9b66c commit 742b3649c0745e0cff66b8f89631ba37d3727036 @tilgovi committed Feb 17, 2010
View
2 debian/control
@@ -9,6 +9,6 @@ Homepage: <insert the upstream URL, if relevant>
Package: couchdb-lounge
Architecture: any
#Depends: ${shlibs:Depends}, ${misc:Depends}, pcre3-dev, python-cjson
-Depends: libpcre3-dev, python-cjson, python-twisted, python-simplejson, python-pyicu
+Depends: libpcre3-dev, python-cjson, python-twisted, python-pyicu
Description: <insert up to 60 chars description>
<insert long description, indented with spaces>
View
4 python-lounge/lounge/__init__.py
@@ -1,5 +1,5 @@
import re
-import simplejson
+import cjson
class ShardMap(object):
def __init__(self, fname=None):
@@ -9,7 +9,7 @@ def __init__(self, fname=None):
self.get_db_shard = re.compile(r'^(.*\D)(\d+)$')
def load_config(self, fname):
- self.config = simplejson.loads(file(fname).read())
+ self.config = cjson.decode(file(fname).read())
self.shardmap = self.config["shard_map"]
self.nodelist = self.config["nodes"]
View
2 smartproxy/check-smartproxy.py
@@ -10,8 +10,6 @@
import traceback
import urllib
-import simplejson
-
from email.Utils import COMMASPACE
from lounge.prefs import Prefs
View
2 smartproxy/smartproxy/reducer.py
@@ -330,7 +330,7 @@ def _do_reduce(self, a, b):
args = [ (key, ["rereduce", [self.reduce_func], to_reducelist(chunk)]) for key,chunk in split_by_key(inp["rows"])]
lines = [cjson.encode(chunk) for key, chunk in args]
keys = [key for key,chunk in args]
- #TODO: maybe this could be lines,keys = zip(*(key, simplejson.dumps(chunk) for key, chunk in args))
+ #TODO: maybe this could be lines,keys = zip(*(key, cjson.encode(chunk) for key, chunk in args))
self.reduces_out += 1
self.reduce_queue.enqueue(keys, lines, self.process_reduce)
else:
View
4 smartproxy/test/couchstub.py
@@ -1,4 +1,4 @@
-import simplejson
+import cjson
import socket
import threading
import time
@@ -80,7 +80,7 @@ def __init__(self, method, path, body, headers):
def reply(self, code, body, headers={}, delay=0):
self.responsecode = code
- self.responsebody = simplejson.dumps(body)
+ self.responsebody = cjson.encode(body)
self.responseheaders = headers
self.delay = delay
if 'content-type' not in [k.lower() for k in self.responseheaders.keys()]:
View
10 smartproxy/test/smartproxy_test.py
@@ -3,7 +3,7 @@
import logging
import os
import pycurl
-import simplejson
+import cjson
import StringIO
import urllib
import urllib2
@@ -16,7 +16,7 @@
class Response:
def __init__(self, code, body, headers):
self.code = code
- self.body = simplejson.loads(body)
+ self.body = cjson.decode(body)
self.headers = headers
def req(url, method, body=None, headers=None):
@@ -26,7 +26,7 @@ def req(url, method, body=None, headers=None):
curl.setopt(pycurl.WRITEFUNCTION, outbuf.write)
if body is not None:
- body = simplejson.dumps(body)
+ body = cjson.encode(body)
if method=='POST':
curl.setopt(pycurl.POSTFIELDS, body)
else:
@@ -191,7 +191,7 @@ def testChanges(self):
],last_seq=14),headers={"Content-Type": "text/plain;charset=utf8"})
be2.listen("localhost", 34567)
- resp = get("http://localhost:22008/funstuff/_changes?since=%s" % urllib.quote(simplejson.dumps([5,12])))
+ resp = get("http://localhost:22008/funstuff/_changes?since=%s" % urllib.quote(cjson.encode([5,12])))
be1.verify()
be2.verify()
@@ -206,7 +206,7 @@ def testChanges(self):
# the order the rows arrive is non-deterministic
seq = [5,12]
def encode(lst):
- return simplejson.dumps(seq)
+ return cjson.encode(seq)
for row in res:
if row["id"] in ["mywallet", "elsegundo"]:
seq[0] += 1
View
8 view_updater/view_updater.py
@@ -14,7 +14,7 @@
#limitations under the License.
from urllib import urlopen, urlencode
-import simplejson
+import cjson
import logging
import time
import lounge
@@ -39,7 +39,7 @@ def get_all_dbs():
except:
logging.error("Failed to retrieve the database list from the local couch node")
raise
- db_json = simplejson.loads(x)
+ db_json = cjson.decode(x)
return db_json
@@ -55,7 +55,7 @@ def get_all_design_docs(db):
except IOError:
logging.exception("Failed trying to fetch %s" % url)
return []
- design_doc_json = simplejson.loads(x)
+ design_doc_json = cjson.decode(x)
design_docs = []
if 'rows' not in design_doc_json:
logging.info ("No design docs in %s" % db)
@@ -79,7 +79,7 @@ def get_views(db, design_doc):
except IOError:
logging.exception("Failed trying to fetch %s" % url)
return []
- design_doc_json = simplejson.loads(x)
+ design_doc_json = cjson.decode(x)
if "views" in design_doc_json:
return design_doc_json['views'].keys()
else:

0 comments on commit 742b364

Please sign in to comment.