]> projects.mako.cc - github-barcamp-201407/blob - ijson-1.1/ijson/backends/__init__.py
import of github code used for the hackathon
[github-barcamp-201407] / ijson-1.1 / ijson / backends / __init__.py
1 from ctypes import util, cdll
2
3 class YAJLImportError(ImportError):
4     pass
5
6 def find_yajl(required):
7     so_name = util.find_library('yajl')
8     if so_name is None:
9         raise YAJLImportError('YAJL shared object not found.')
10     yajl = cdll.LoadLibrary(so_name)
11     major, rest = divmod(yajl.yajl_version(), 10000)
12     minor, micro = divmod(rest, 100)
13     if major != required:
14         raise YAJLImportError('YAJL version %s.x required, found %s.%s.%s' % (required, major, minor, micro))
15     return yajl

Benjamin Mako Hill || Want to submit a patch?