From f7b648f5281e17dfee86fe8eb048d5ff0a19ca81 Mon Sep 17 00:00:00 2001 From: Daniel Hermes Date: Wed, 6 Mar 2013 09:38:53 -0800 Subject: [PATCH] Fixing lint errors. Fixes Issue 244. Reviewed in https://codereview.appspot.com/7516043/ --- apiclient/discovery.py | 30 +++++++++++++++++----------- oauth2client/appengine.py | 8 +------- tests/test_errors.py | 2 +- tests/test_oauth2client.py | 8 ++++---- tests/test_oauth2client_appengine.py | 6 +++--- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/apiclient/discovery.py b/apiclient/discovery.py index 19af41a..4c6cb60 100644 --- a/apiclient/discovery.py +++ b/apiclient/discovery.py @@ -25,23 +25,30 @@ __all__ = [ 'key2param', ] + +# Standard library imports import copy -import httplib2 +from email.mime.multipart import MIMEMultipart +from email.mime.nonmultipart import MIMENonMultipart import keyword import logging +import mimetypes import os import re -import uritemplate import urllib import urlparse -import mimeparse -import mimetypes try: from urlparse import parse_qsl except ImportError: from cgi import parse_qsl +# Third-party imports +import httplib2 +import mimeparse +import uritemplate + +# Local imports from apiclient.errors import HttpError from apiclient.errors import InvalidJsonError from apiclient.errors import MediaUploadSizeError @@ -55,11 +62,10 @@ from apiclient.model import JsonModel from apiclient.model import MediaModel from apiclient.model import RawModel from apiclient.schema import Schemas -from email.mime.multipart import MIMEMultipart -from email.mime.nonmultipart import MIMENonMultipart -from oauth2client.util import positional -from oauth2client.util import _add_query_parameter from oauth2client.anyjson import simplejson +from oauth2client.util import _add_query_parameter +from oauth2client.util import positional + # The client library requires a version of httplib2 that supports RETRIES. httplib2.RETRIES = 1 @@ -79,10 +85,10 @@ BODY_PARAMETER_DEFAULT_VALUE = { 'required': True, } MEDIA_BODY_PARAMETER_DEFAULT_VALUE = { - 'description': ('The filename of the media request body, or an instance ' - 'of a MediaUpload object.'), - 'type': 'string', - 'required': False, + 'description': ('The filename of the media request body, or an instance ' + 'of a MediaUpload object.'), + 'type': 'string', + 'required': False, } # Parameters accepted by the stack, but not visible via discovery. diff --git a/oauth2client/appengine.py b/oauth2client/appengine.py index 570f0f5..a6d88df 100644 --- a/oauth2client/appengine.py +++ b/oauth2client/appengine.py @@ -26,8 +26,6 @@ import logging import os import pickle import time -import urllib -import urlparse from google.appengine.api import app_identity from google.appengine.api import memcache @@ -57,10 +55,6 @@ try: except ImportError: ndb = None -try: - from urlparse import parse_qsl -except ImportError: - from cgi import parse_qsl logger = logging.getLogger(__name__) @@ -799,7 +793,7 @@ class OAuth2Decorator(object): if decorator._token_response_param and credentials.token_response: resp_json = simplejson.dumps(credentials.token_response) redirect_uri = util._add_query_parameter( - redirect_uri, decorator._token_response_param, resp_json) + redirect_uri, decorator._token_response_param, resp_json) self.redirect(redirect_uri) diff --git a/tests/test_errors.py b/tests/test_errors.py index 57e82e7..bd6c6d5 100644 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -94,6 +94,6 @@ class Error(unittest.TestCase): def test_missing_reason(self): """Test an empty dict with a missing resp.reason.""" - resp, content = fake_response('}NOT OK', {'status':'400'}, reason=None) + resp, content = fake_response('}NOT OK', {'status': '400'}, reason=None) error = HttpError(resp, content) self.assertEqual(str(error), '') diff --git a/tests/test_oauth2client.py b/tests/test_oauth2client.py index f824f60..a075e1f 100644 --- a/tests/test_oauth2client.py +++ b/tests/test_oauth2client.py @@ -144,10 +144,10 @@ class BasicCredentialsTests(unittest.TestCase): for status_code in REFRESH_STATUS_CODES: token_response = {'access_token': '1/3w', 'expires_in': 3600} http = HttpMockSequence([ - ({'status': status_code}, ''), - ({'status': '200'}, simplejson.dumps(token_response)), - ({'status': '200'}, 'echo_request_headers'), - ]) + ({'status': status_code}, ''), + ({'status': '200'}, simplejson.dumps(token_response)), + ({'status': '200'}, 'echo_request_headers'), + ]) http = self.credentials.authorize(http) resp, content = http.request('http://example.com') self.assertEqual('Bearer 1/3w', content['Authorization']) diff --git a/tests/test_oauth2client_appengine.py b/tests/test_oauth2client_appengine.py index 20e8f09..e613f2b 100644 --- a/tests/test_oauth2client_appengine.py +++ b/tests/test_oauth2client_appengine.py @@ -510,9 +510,9 @@ class DecoratorTests(unittest.TestCase): self.assertEqual('http://localhost/foo_path', parts[0]) self.assertEqual(None, self.decorator.credentials) if self.decorator._token_response_param: - response = parse_qs(parts[1])[self.decorator._token_response_param][0] - self.assertEqual(Http2Mock.content, - simplejson.loads(urllib.unquote(response))) + response = parse_qs(parts[1])[self.decorator._token_response_param][0] + self.assertEqual(Http2Mock.content, + simplejson.loads(urllib.unquote(response))) m.UnsetStubs() m.VerifyAll()