Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move is_installed from setup.py to jsonpickle.util so it can be used …

…to check for backends' existence.
  • Loading branch information...
commit afbd7696c7896fc7d9c577b53f0b4c8743065751 1 parent 6de3e5a
@johnpaulett johnpaulett authored
Showing with 17 additions and 7 deletions.
  1. +16 −0 jsonpickle/util.py
  2. +1 −7 setup.py
View
16 jsonpickle/util.py
@@ -210,3 +210,19 @@ def is_picklable(name, value):
if name in tags.RESERVED:
return False
return not is_function(value)
+
+def is_installed(module):
+ """Tests to see if ``module`` is available on the sys.path
+
+ >>> is_installed('sys')
+ True
+ >>> is_installed('hopefullythisisnotarealmodule')
+ False
+
+ """
+ try:
+ __import__(module)
+ return True
+ except ImportError, e:
+ return False
+
View
8 setup.py
@@ -47,17 +47,11 @@ def main():
def _check_dependencies():
# check to see if any of the supported backends is installed
backends = _jsonpickle.SUPPORTED_BACKENDS
- if not any([_is_installed(module) for module in backends]):
+ if not any([_jsonpickle.util.is_installed(module) for module in backends]):
print >> sys.stderr, ('No supported JSON backend found. '
'Must install one of %s' % (', '.join(backends)))
sys.exit(1)
-def _is_installed(module):
- try:
- __import__(module)
- return True
- except ImportError, e:
- return False
if __name__ == '__main__':
sys.exit(main())
Please sign in to comment.
Something went wrong with that request. Please try again.