[OpenLayers-Commits] r11259 - trunk/openlayers/tools

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Tue Feb 22 15:55:36 EST 2011


Author: tschaub
Date: 2011-02-22 12:55:36 -0800 (Tue, 22 Feb 2011)
New Revision: 11259

Modified:
   trunk/openlayers/tools/exampleparser.py
Log:
Working with json if available.  Fall back to simplejson.

Modified: trunk/openlayers/tools/exampleparser.py
===================================================================
--- trunk/openlayers/tools/exampleparser.py	2011-02-22 16:48:05 UTC (rev 11258)
+++ trunk/openlayers/tools/exampleparser.py	2011-02-22 20:55:36 UTC (rev 11259)
@@ -20,7 +20,14 @@
 
 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 @@
 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 @@
     
     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)



More information about the Commits mailing list