Fixes issue #85. Also moves all json imports to go through oauth2client.anyjson. Reviewed in http://codereview.appspot.com/5531064/.
diff --git a/apiclient/anyjson.py b/apiclient/anyjson.py
deleted file mode 100644
index 7fb7846..0000000
--- a/apiclient/anyjson.py
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright (C) 2010 Google Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Utility module to import a JSON module
-
-Hides all the messy details of exactly where
-we get a simplejson module from.
-"""
-
-__author__ = 'jcgregorio@google.com (Joe Gregorio)'
-
-
-try: # pragma: no cover
- import simplejson
-except ImportError: # pragma: no cover
- 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
diff --git a/apiclient/discovery.py b/apiclient/discovery.py
index 9344392..a2c81c6 100644
--- a/apiclient/discovery.py
+++ b/apiclient/discovery.py
@@ -39,7 +39,6 @@
except ImportError:
from cgi import parse_qsl
-from apiclient.anyjson import simplejson
from apiclient.errors import HttpError
from apiclient.errors import InvalidJsonError
from apiclient.errors import MediaUploadSizeError
@@ -54,6 +53,7 @@
from apiclient.schema import Schemas
from email.mime.multipart import MIMEMultipart
from email.mime.nonmultipart import MIMENonMultipart
+from oauth2client.anyjson import simplejson
URITEMPLATE = re.compile('{[^}]*}')
diff --git a/apiclient/errors.py b/apiclient/errors.py
index fca3960..b6ee9a5 100644
--- a/apiclient/errors.py
+++ b/apiclient/errors.py
@@ -23,7 +23,7 @@
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
-from anyjson import simplejson
+from oauth2client.anyjson import simplejson
class Error(Exception):
diff --git a/apiclient/http.py b/apiclient/http.py
index 6bf1de4..4563bd1 100644
--- a/apiclient/http.py
+++ b/apiclient/http.py
@@ -36,7 +36,6 @@
import urlparse
import uuid
-from anyjson import simplejson
from email.mime.multipart import MIMEMultipart
from email.mime.nonmultipart import MIMENonMultipart
from email.parser import FeedParser
@@ -46,6 +45,7 @@
from errors import UnexpectedBodyError
from errors import UnexpectedMethodError
from model import JsonModel
+from oauth2client.anyjson import simplejson
class MediaUploadProgress(object):
diff --git a/apiclient/model.py b/apiclient/model.py
index 7f40efa..aafd88b 100644
--- a/apiclient/model.py
+++ b/apiclient/model.py
@@ -28,8 +28,8 @@
import logging
import urllib
-from anyjson import simplejson
from errors import HttpError
+from oauth2client.anyjson import simplejson
FLAGS = gflags.FLAGS
diff --git a/apiclient/oauth.py b/apiclient/oauth.py
index 11eb680..bd4125b 100644
--- a/apiclient/oauth.py
+++ b/apiclient/oauth.py
@@ -26,7 +26,8 @@
import oauth2 as oauth
import urllib
import urlparse
-from anyjson import simplejson
+
+from oauth2client.anyjson import simplejson
try:
from urlparse import parse_qsl
diff --git a/apiclient/schema.py b/apiclient/schema.py
index cd5a7cb..ddcd670 100644
--- a/apiclient/schema.py
+++ b/apiclient/schema.py
@@ -62,7 +62,7 @@
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
import copy
-from apiclient.anyjson import simplejson
+from oauth2client.anyjson import simplejson
class Schemas(object):
@@ -262,13 +262,13 @@
self.emitEnd('%s,' % str(value), schema.get('description', ''))
elif stype == 'string':
value = schema.get('default', 'A String')
- self.emitEnd('"%s",' % value, schema.get('description', ''))
+ self.emitEnd('"%s",' % str(value), schema.get('description', ''))
elif stype == 'integer':
- value = schema.get('default', 42)
- self.emitEnd('%d,' % value, schema.get('description', ''))
+ value = schema.get('default', '42')
+ self.emitEnd('%s,' % str(value), schema.get('description', ''))
elif stype == 'number':
- value = schema.get('default', 3.14)
- self.emitEnd('%f,' % value, schema.get('description', ''))
+ value = schema.get('default', '3.14')
+ self.emitEnd('%s,' % str(value), schema.get('description', ''))
elif stype == 'null':
self.emitEnd('None,', schema.get('description', ''))
elif stype == 'any':