\r
check_twisted()\r
check_win32()\r
+ i+=check_json()\r
i+=check_java()\r
i+=check_hg()\r
\r
import twisted.words\r
except ImportError:\r
twisted_fail("words")\r
-\r
+ \r
+def check_json():\r
+ import qwebirc.util.qjson\r
+ if qwebirc.util.qjson.slow:\r
+ warn("simplejson module with C speedups not installed.",\r
+ "using embedded module (slower); consider installing simplejson from:",\r
+ "http://pypi.python.org/pypi/simplejson/")\r
+ return 1\r
+ return 0\r
+ \r
if __name__ == "__main__":\r
import dependencies\r
dependencies.check_dependencies()\r
compile.main(DEST, produce_debug=False)
- for x in "authgate qwebirc simplejson twisted".split(" "):
+ for x in "authgate qwebirc esimplejson twisted".split(" "):
copypydir(x, DEST)
for x in "images panes sound".split(" "):
copydir(os.path.join("static", x), DEST)
-import config, simplejson
+import config
+import qwebirc.util.qjson as json
def get_options():
options = dict(networkName=config.NETWORK_NAME, networkServices=[config.AUTH_SERVICE], loginRegex=config. AUTH_OK_REGEX, appTitle=config.APP_TITLE, baseURL=config.BASE_URL)
- return simplejson.dumps(options)
+ return json.dumps(options)
]
if __name__ == '__main__':
- from simplejson.decoder import JSONDecoder
- from simplejson.encoder import JSONEncoder
+ from esimplejson.decoder import JSONDecoder
+ from esimplejson.encoder import JSONEncoder
else:
from decoder import JSONDecoder
from encoder import JSONEncoder
import re
import sys
-from simplejson.scanner import Scanner, pattern
+from esimplejson.scanner import Scanner, pattern
try:
- from simplejson._speedups import scanstring as c_scanstring
+ from esimplejson._speedups import scanstring as c_scanstring
except ImportError:
pass
import re
try:
- from simplejson._speedups import encode_basestring_ascii as c_encode_basestring_ascii
+ from esimplejson._speedups import encode_basestring_ascii as c_encode_basestring_ascii
except ImportError:
pass
from twisted.names import client
from twisted.internet import reactor, error
from authgateengine import login_optional, getSessionData
-import simplejson, md5, sys, os, time, config, qwebirc.config_options as config_options, traceback, socket
+import md5, sys, os, time, config, qwebirc.config_options as config_options, traceback, socket
import qwebirc.ircclient as ircclient
from adminengine import AdminEngineAction
from qwebirc.util import HitCounter
import qwebirc.dns as qdns
+import qwebirc.util.qjson as json
Sessions = {}
def get_session_id():
pass
NOT_DONE_YET = None
+EMPTY_JSON_LIST = json.dumps([])
def jsondump(fn):
def decorator(*args, **kwargs):
except PassthruException, e:
return str(e)
- return simplejson.dumps(x)
+ return json.dumps(x)
return decorator
def cleanupSession(id):
if self.schedule:
return
- channel.write(simplejson.dumps([]))
+ channel.write(EMPTY_JSON_LIST)
if channel in self.subscriptions:
self.subscriptions.remove(channel)
self.throttle = t + config.UPDATE_FREQ
- encdata = simplejson.dumps(self.buffer)
+ encdata = json.dumps(self.buffer)
self.buffer = []
self.buflen = 0
--- /dev/null
+slow = True
+try:
+ # first try the system module
+ import simplejson as json
+ try:
+ # try to see if the C module is available
+ json._speedups
+ except AttributeError:
+ pass
+ else:
+ slow = False
+except ImportError:
+ # try python 2.6's json library as
+ # it is 2x as fast as simplejson with no C
+ try:
+ import json
+ json.dumps # we don't want the silly third party version
+ except (ImportError, AttributeError):
+ # fallback to the embedded
+ import esimplejson as json
+
+__SEPS = (',', ':')
+dumps = lambda x: json.dumps(x, encoding="utf8", ensure_ascii=True, check_circular=False, indent=None, separators=__SEPS)
+loads = lambda x: json.loads(x, encoding="utf8")