Working with json if available. Fall back to simplejson.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@11259 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -20,7 +20,14 @@ except ImportError:
|
|||||||
|
|
||||||
missing_deps = False
|
missing_deps = False
|
||||||
try:
|
try:
|
||||||
import simplejson
|
import json
|
||||||
|
except ImportError:
|
||||||
|
try:
|
||||||
|
import simplejson as json
|
||||||
|
except ImportError, E:
|
||||||
|
missing_deps = E
|
||||||
|
|
||||||
|
try:
|
||||||
from BeautifulSoup import BeautifulSoup
|
from BeautifulSoup import BeautifulSoup
|
||||||
except ImportError, E:
|
except ImportError, E:
|
||||||
missing_deps = E
|
missing_deps = E
|
||||||
@@ -196,7 +203,7 @@ def wordIndex(examples):
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
if missing_deps:
|
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()
|
sys.exit()
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
@@ -237,7 +244,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
index = wordIndex(exampleList)
|
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.
|
#give the json a global variable we can use in our js. This should be replaced or made optional.
|
||||||
json = 'var info=' + json
|
json = 'var info=' + json
|
||||||
outFile.write(json)
|
outFile.write(json)
|
||||||
|
|||||||
Reference in New Issue
Block a user