From 446ae5b15ab9d119d29f64f2b6b601b2689d3ab4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mat=C3=ADas=20Aguirre?= Date: Fri, 30 Dec 2011 16:50:19 -0200 Subject: [PATCH] Small PEP8 fixes and import orders --- social_auth/backends/__init__.py | 4 ---- social_auth/backends/contrib/dropbox.py | 5 ++++- social_auth/backends/contrib/flickr.py | 2 +- social_auth/backends/contrib/foursquare.py | 3 +-- social_auth/backends/contrib/github.py | 4 ++-- social_auth/backends/contrib/livejournal.py | 3 +-- social_auth/backends/contrib/orkut.py | 3 +-- social_auth/backends/pipeline/social.py | 2 +- social_auth/backends/pipeline/user.py | 3 ++- 9 files changed, 13 insertions(+), 16 deletions(-) diff --git a/social_auth/backends/__init__.py b/social_auth/backends/__init__.py index e37afbb..29e368b 100644 --- a/social_auth/backends/__init__.py +++ b/social_auth/backends/__init__.py @@ -12,12 +12,9 @@ enabled. import logging logger = logging.getLogger(__name__) -from os import walk -from os.path import basename from urllib2 import Request, urlopen from urllib import urlencode from urlparse import urlsplit -from collections import defaultdict from openid.consumer.consumer import Consumer, SUCCESS, CANCEL, FAILURE from openid.consumer.discover import DiscoveryFailure @@ -33,7 +30,6 @@ from django.contrib.auth.backends import ModelBackend from django.utils import simplejson from django.utils.importlib import import_module -from social_auth.models import UserSocialAuth from social_auth.utils import setting from social_auth.store import DjangoOpenIDStore from social_auth.backends.exceptions import StopPipeline diff --git a/social_auth/backends/contrib/dropbox.py b/social_auth/backends/contrib/dropbox.py index cc26d0b..0a140fb 100644 --- a/social_auth/backends/contrib/dropbox.py +++ b/social_auth/backends/contrib/dropbox.py @@ -13,6 +13,7 @@ from django.utils import simplejson from social_auth.backends import ConsumerBasedOAuth, OAuthBackend, USERNAME + # Dropbox configuration DROPBOX_SERVER = 'dropbox.com' DROPBOX_API = 'api.%s' % DROPBOX_SERVER @@ -33,12 +34,13 @@ class DropboxBackend(OAuthBackend): return {USERNAME: response.get('uid'), 'email': response.get('email'), 'first_name': response.get('display_name')} - + def get_user_id(self, details, response): """OAuth providers return an unique user id in response""" # Dropbox uses a uid parameter instead of id like most others... return response['uid'] + class DropboxAuth(ConsumerBasedOAuth): """Dropbox OAuth authentication mechanism""" AUTHORIZATION_URL = DROPBOX_AUTHORIZATION_URL @@ -66,6 +68,7 @@ class DropboxAuth(ConsumerBasedOAuth): ('DROPBOX_APP_ID', 'DROPBOX_API_SECRET')) + # Backend definition BACKENDS = { 'dropbox': DropboxAuth, diff --git a/social_auth/backends/contrib/flickr.py b/social_auth/backends/contrib/flickr.py index e221bb4..b61db38 100644 --- a/social_auth/backends/contrib/flickr.py +++ b/social_auth/backends/contrib/flickr.py @@ -16,11 +16,11 @@ except ImportError: from cgi import parse_qs from django.conf import settings -from django.utils import simplejson from oauth2 import Token from social_auth.backends import ConsumerBasedOAuth, OAuthBackend, USERNAME + # Flickr configuration FLICKR_SERVER = 'http://www.flickr.com/services' FLICKR_REQUEST_TOKEN_URL = '%s/oauth/request_token' % FLICKR_SERVER diff --git a/social_auth/backends/contrib/foursquare.py b/social_auth/backends/contrib/foursquare.py index 86dc7b9..d4a04f6 100644 --- a/social_auth/backends/contrib/foursquare.py +++ b/social_auth/backends/contrib/foursquare.py @@ -1,8 +1,7 @@ +import urllib import logging logger = logging.getLogger(__name__) -import urllib - from django.utils import simplejson from social_auth.backends import BaseOAuth2, OAuthBackend, USERNAME diff --git a/social_auth/backends/contrib/github.py b/social_auth/backends/contrib/github.py index b24462a..3b13835 100644 --- a/social_auth/backends/contrib/github.py +++ b/social_auth/backends/contrib/github.py @@ -11,11 +11,11 @@ setting, it must be a list of values to request. By default account id and token expiration time are stored in extra_data field, check OAuthBackend class for details on how to extend it. """ +import cgi +import urllib import logging logger = logging.getLogger(__name__) -import cgi -import urllib from django.conf import settings from django.utils import simplejson diff --git a/social_auth/backends/contrib/livejournal.py b/social_auth/backends/contrib/livejournal.py index b5ca7e0..2e516a0 100644 --- a/social_auth/backends/contrib/livejournal.py +++ b/social_auth/backends/contrib/livejournal.py @@ -4,11 +4,10 @@ LiveJournal OpenID support. This contribution adds support for LiveJournal OpenID service in the form username.livejournal.com. Username is retrieved from the identity url. """ +import urlparse import logging logger = logging.getLogger(__name__) -import urlparse - from social_auth.backends import OpenIDBackend, OpenIdAuth, USERNAME diff --git a/social_auth/backends/contrib/orkut.py b/social_auth/backends/contrib/orkut.py index ce3ef06..c426dab 100644 --- a/social_auth/backends/contrib/orkut.py +++ b/social_auth/backends/contrib/orkut.py @@ -10,11 +10,10 @@ can be specified by defining ORKUT_EXTRA_DATA setting. OAuth settings ORKUT_CONSUMER_KEY and ORKUT_CONSUMER_SECRET are needed to enable this service support. """ +import urllib import logging logger = logging.getLogger(__name__) -import urllib - from django.conf import settings from django.utils import simplejson diff --git a/social_auth/backends/pipeline/social.py b/social_auth/backends/pipeline/social.py index 6b241ac..604fb8c 100644 --- a/social_auth/backends/pipeline/social.py +++ b/social_auth/backends/pipeline/social.py @@ -1,7 +1,7 @@ from django.conf import settings from django.db.utils import IntegrityError -from social_auth.models import User, UserSocialAuth +from social_auth.models import UserSocialAuth from social_auth.backends.pipeline import warn_setting diff --git a/social_auth/backends/pipeline/user.py b/social_auth/backends/pipeline/user.py index af58ee3..b1acc48 100644 --- a/social_auth/backends/pipeline/user.py +++ b/social_auth/backends/pipeline/user.py @@ -3,7 +3,8 @@ from uuid import uuid4 from django.conf import settings from social_auth.models import User -from social_auth.backends.pipeline import USERNAME, USERNAME_MAX_LENGTH, warn_setting +from social_auth.backends.pipeline import USERNAME, USERNAME_MAX_LENGTH, \ + warn_setting from social_auth.signals import socialauth_not_registered, \ socialauth_registered, \ pre_update -- 2.39.5