Be flexible where simplejson comes from

This commit is contained in:
Joe Gregorio
2010-09-20 11:13:50 -04:00
parent e936958c8b
commit e6efd5359b
2 changed files with 21 additions and 3 deletions

View File

@@ -25,11 +25,20 @@ import httplib2
import logging
import os
import re
import simplejson
import uritemplate
import urllib
import urlparse
try:
import simplejson
except ImportError:
try:
# Try to import from django, should work on App Engine
from django.utils import simplejson
except ImportError:
# Should work for Python2.6 and higher.
import json as simplejson
class HttpError(Exception):
pass

View File

@@ -23,9 +23,19 @@ __author__ = 'jcgregorio@google.com (Joe Gregorio)'
import os
import os.path
import simplejson
import sys
try:
import simplejson
except ImportError:
try:
# Try to import from django, should work on App Engine
from django.utils import simplejson
except ImportError:
# Should work for Python2.6 and higher.
import json as simplejson
def main():
for filename in sys.argv[1:]:
f = file(filename, "r")
@@ -49,4 +59,3 @@ def main():
if __name__ == '__main__':
main()