From 078d267511ee2f089c6445845114f478197f166f Mon Sep 17 00:00:00 2001 From: Rune Halvorsen Date: Thu, 23 Jul 2009 00:11:44 +0200 Subject: [PATCH] Removed support for -m since we're a package now and so it doesn't work. (add a command line entry point later on if we really need that functionality) Moved parts of the docs back to __init__.py --- anyjson/__init__.py | 40 +++++++++++++++++++++------------------- anyjson/metadata.py | 21 +-------------------- 2 files changed, 22 insertions(+), 39 deletions(-) diff --git a/anyjson/__init__.py b/anyjson/__init__.py index 40cce49..bc74885 100644 --- a/anyjson/__init__.py +++ b/anyjson/__init__.py @@ -6,6 +6,24 @@ __doc__ = metadata.__doc__ implementation = None """ +.. function:: serialize(obj) + + Serialize the object to JSON. + +.. function:: deserialize(str) + + Deserialize JSON-encoded object to a Python object. + +.. function:: force_implementation(name) + + Load a specific json module. This is useful for testing and not much else + +.. attribute:: implementation + + The json implementation object. This is probably not useful to you, + except to get the name of the implementation in use. The name is + available through `implementation.name`. + .. data:: _modules List of known json modules, and the names of their serialize/unserialize @@ -80,29 +98,13 @@ def force_implementation(modname): raise ImportError("No module named: %s" % modname) - -def main(): - installed = [] - for modspec in _modules: - try: - __import__(modspec[0]) - installed.append(modspec[0]) - except ImportError: - pass - - if installed: - print "Supported JSON modules found:", ", ".join(installed) - return 0 - else: - print "No supported JSON modules found" - return 1 - if __name__ == "__main__": - # If run as a script, we simply print what is installed that we support. + # If run as a script, we do nothing but print an error message. # We do NOT try to load a compatible module because that may throw an # exception, which renders the package uninstallable with easy_install # (It trys to execfile the script when installing, to make sure it works) - sys.exit(main()) + print "Running anyjson as a stand alone script is not supported" + sys.exit(1) else: for modspec in _modules: try: diff --git a/anyjson/metadata.py b/anyjson/metadata.py index a23b135..f44766b 100644 --- a/anyjson/metadata.py +++ b/anyjson/metadata.py @@ -1,24 +1,5 @@ """Wraps the best available JSON implementation available in a common -interface - -.. function:: serialize(obj) - - Serialize the object to JSON. - -.. function:: deserialize(str) - - Deserialize JSON-encoded object to a Python object. - -.. function:: force_implementation(name) - - Load a specific json module. This is useful for testing and not much else - -.. attribute:: implementation - - The json implementation object. This is probably not useful to you, - except to get the name of the implementation in use. The name is - available through `implementation.name`. -""" +interface""" # Note: This module is neccessary so we can load the metadata in setup.py # without risking that the module loading fails. It will fail if the user