Fixes issue #85. Also moves all json imports to go through oauth2client.anyjson. Reviewed in http://codereview.appspot.com/5531064/.
This commit is contained in:
1
Makefile
1
Makefile
@@ -17,6 +17,7 @@ test:
|
||||
python runtests.py tests/test_oauth2client.py
|
||||
python runtests.py tests/test_oauth.py
|
||||
python runtests.py tests/test_protobuf_model.py
|
||||
python runtests.py tests/test_schema.py
|
||||
python runtests.py tests/test_oauth2client_appengine.py
|
||||
|
||||
.PHONY: docs
|
||||
|
||||
@@ -39,7 +39,6 @@ try:
|
||||
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.model import RawModel
|
||||
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('{[^}]*}')
|
||||
|
||||
@@ -23,7 +23,7 @@ should be defined in this file.
|
||||
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
|
||||
|
||||
|
||||
from anyjson import simplejson
|
||||
from oauth2client.anyjson import simplejson
|
||||
|
||||
|
||||
class Error(Exception):
|
||||
|
||||
@@ -36,7 +36,6 @@ import urllib
|
||||
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 ResumableUploadError
|
||||
from errors import UnexpectedBodyError
|
||||
from errors import UnexpectedMethodError
|
||||
from model import JsonModel
|
||||
from oauth2client.anyjson import simplejson
|
||||
|
||||
|
||||
class MediaUploadProgress(object):
|
||||
|
||||
@@ -28,8 +28,8 @@ import gflags
|
||||
import logging
|
||||
import urllib
|
||||
|
||||
from anyjson import simplejson
|
||||
from errors import HttpError
|
||||
from oauth2client.anyjson import simplejson
|
||||
|
||||
FLAGS = gflags.FLAGS
|
||||
|
||||
|
||||
@@ -26,7 +26,8 @@ import logging
|
||||
import oauth2 as oauth
|
||||
import urllib
|
||||
import urlparse
|
||||
from anyjson import simplejson
|
||||
|
||||
from oauth2client.anyjson import simplejson
|
||||
|
||||
try:
|
||||
from urlparse import parse_qsl
|
||||
|
||||
@@ -62,7 +62,7 @@ The constructor takes a discovery document in which to look up named schema.
|
||||
__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 @@ class _SchemaToStruct(object):
|
||||
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':
|
||||
|
||||
@@ -22,11 +22,11 @@ __author__ = 'jcgregorio@google.com (Joe Gregorio)'
|
||||
|
||||
|
||||
try: # pragma: no cover
|
||||
import simplejson
|
||||
# Should work for Python2.6 and higher.
|
||||
import json as simplejson
|
||||
except ImportError: # pragma: no cover
|
||||
try:
|
||||
import simplejson
|
||||
except ImportError:
|
||||
# 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
|
||||
@@ -25,18 +25,9 @@ import logging
|
||||
import pickle
|
||||
import time
|
||||
|
||||
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
|
||||
|
||||
import clientsecrets
|
||||
|
||||
from anyjson import simplejson
|
||||
from client import AccessTokenRefreshError
|
||||
from client import AssertionCredentials
|
||||
from client import Credentials
|
||||
|
||||
@@ -31,6 +31,7 @@ import time
|
||||
import urllib
|
||||
import urlparse
|
||||
|
||||
from anyjson import simplejson
|
||||
|
||||
HAS_OPENSSL = False
|
||||
try:
|
||||
@@ -41,16 +42,6 @@ try:
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
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
|
||||
|
||||
try:
|
||||
from urlparse import parse_qsl
|
||||
except ImportError:
|
||||
|
||||
@@ -21,15 +21,7 @@ an OAuth 2.0 protected service.
|
||||
__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
|
||||
from anyjson import simplejson
|
||||
|
||||
# Properties that make a client_secrets.json file valid.
|
||||
TYPE_WEB = 'web'
|
||||
|
||||
@@ -21,16 +21,7 @@ import logging
|
||||
import time
|
||||
|
||||
from OpenSSL import crypto
|
||||
|
||||
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
|
||||
from anyjson import simplejson
|
||||
|
||||
|
||||
CLOCK_SKEW_SECS = 300 # 5 minutes in seconds
|
||||
|
||||
@@ -22,18 +22,7 @@ __author__ = 'jcgregorio@google.com (Joe Gregorio)'
|
||||
|
||||
import threading
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
from anyjson import simplejson
|
||||
from client import Storage as BaseStorage
|
||||
from client import Credentials
|
||||
|
||||
|
||||
@@ -37,16 +37,7 @@ import logging
|
||||
import os
|
||||
import threading
|
||||
|
||||
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
|
||||
|
||||
from anyjson import simplejson
|
||||
from client import Storage as BaseStorage
|
||||
from client import Credentials
|
||||
|
||||
|
||||
@@ -28,9 +28,9 @@ import unittest
|
||||
import httplib2
|
||||
import apiclient.model
|
||||
|
||||
from apiclient.anyjson import simplejson
|
||||
from apiclient.errors import HttpError
|
||||
from apiclient.model import JsonModel
|
||||
from oauth2client.anyjson import simplejson
|
||||
|
||||
FLAGS = gflags.FLAGS
|
||||
|
||||
|
||||
@@ -33,17 +33,8 @@ try:
|
||||
except ImportError:
|
||||
from cgi import parse_qs
|
||||
|
||||
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
|
||||
|
||||
from apiclient.http import HttpMockSequence
|
||||
from oauth2client.anyjson import simplejson
|
||||
from oauth2client.client import AccessTokenCredentials
|
||||
from oauth2client.client import AccessTokenCredentialsError
|
||||
from oauth2client.client import AccessTokenRefreshError
|
||||
|
||||
@@ -35,18 +35,18 @@ except ImportError:
|
||||
import dev_appserver
|
||||
dev_appserver.fix_sys_path()
|
||||
|
||||
from apiclient.anyjson import simplejson
|
||||
from apiclient.http import HttpMockSequence
|
||||
from google.appengine.api import apiproxy_stub
|
||||
from google.appengine.api import apiproxy_stub_map
|
||||
from google.appengine.api import users
|
||||
from google.appengine.ext import testbed
|
||||
from google.appengine.ext import webapp
|
||||
from oauth2client.client import AccessTokenRefreshError
|
||||
from oauth2client.client import FlowExchangeError
|
||||
from oauth2client.anyjson import simplejson
|
||||
from oauth2client.appengine import AppAssertionCredentials
|
||||
from oauth2client.appengine import OAuth2Decorator
|
||||
from oauth2client.appengine import OAuth2Handler
|
||||
from oauth2client.client import AccessTokenRefreshError
|
||||
from oauth2client.client import FlowExchangeError
|
||||
from webtest import TestApp
|
||||
|
||||
|
||||
|
||||
@@ -30,24 +30,13 @@ import pickle
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
|
||||
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
|
||||
|
||||
from apiclient.http import HttpMockSequence
|
||||
|
||||
from oauth2client.client import OAuth2Credentials
|
||||
from oauth2client import multistore_file
|
||||
from oauth2client.anyjson import simplejson
|
||||
from oauth2client.client import AccessTokenCredentials
|
||||
from oauth2client.client import AssertionCredentials
|
||||
from oauth2client.client import OAuth2Credentials
|
||||
from oauth2client.file import Storage
|
||||
from oauth2client import multistore_file
|
||||
|
||||
|
||||
FILENAME = tempfile.mktemp('oauth2client_test.data')
|
||||
|
||||
@@ -34,21 +34,12 @@ try:
|
||||
except ImportError:
|
||||
from cgi import parse_qs
|
||||
|
||||
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
|
||||
|
||||
from apiclient.http import HttpMockSequence
|
||||
from oauth2client import crypt
|
||||
from oauth2client.anyjson import simplejson
|
||||
from oauth2client.client import SignedJwtAssertionCredentials
|
||||
from oauth2client.client import verify_id_token
|
||||
from oauth2client.client import VerifyJwtTokenError
|
||||
from oauth2client.client import verify_id_token
|
||||
|
||||
|
||||
def datafile(filename):
|
||||
|
||||
@@ -20,8 +20,8 @@ import os
|
||||
import unittest
|
||||
import StringIO
|
||||
|
||||
from apiclient.anyjson import simplejson
|
||||
from apiclient.schema import Schemas
|
||||
from oauth2client.anyjson import simplejson
|
||||
|
||||
|
||||
DATA_DIR = os.path.join(os.path.dirname(__file__), 'data')
|
||||
@@ -39,7 +39,7 @@ LOAD_FEED = """{
|
||||
"anyVal": "", # Anything will do.
|
||||
"nullVal": None,
|
||||
"stringVal": "A String",
|
||||
"doubleVal": 3.140000,
|
||||
"doubleVal": 3.14,
|
||||
"booleanVal": True or False, # True or False.
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user