From 1619f0801bb24dd69c1ac937ae75d8de9f02ddf7 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 22 Feb 2011 20:55:36 +0000 Subject: [PATCH] Working with json if available. Fall back to simplejson. git-svn-id: http://svn.openlayers.org/trunk/openlayers@11259 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- tools/exampleparser.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/exampleparser.py b/tools/exampleparser.py index 9ee16ea29e..593d2fd181 100755 --- a/tools/exampleparser.py +++ b/tools/exampleparser.py @@ -20,7 +20,14 @@ except ImportError: missing_deps = False try: - import simplejson + import json +except ImportError: + try: + import simplejson as json + except ImportError, E: + missing_deps = E + +try: from BeautifulSoup import BeautifulSoup except ImportError, E: missing_deps = E @@ -196,7 +203,7 @@ def wordIndex(examples): if __name__ == "__main__": if missing_deps: - print "This script requires simplejson and BeautifulSoup. You don't have them. \n(%s)" % E + print "This script requires json or simplejson and BeautifulSoup. You don't have them. \n(%s)" % E sys.exit() if len(sys.argv) > 1: @@ -237,7 +244,7 @@ if __name__ == "__main__": index = wordIndex(exampleList) - json = simplejson.dumps({"examples": exampleList, "index": index}) + json = json.dumps({"examples": exampleList, "index": index}) #give the json a global variable we can use in our js. This should be replaced or made optional. json = 'var info=' + json outFile.write(json)