]> git.parisson.com Git - django-social-auth.git/commitdiff
PEP8
authorMatías Aguirre <matiasaguirre@gmail.com>
Thu, 1 Mar 2012 15:42:58 +0000 (13:42 -0200)
committerMatías Aguirre <matiasaguirre@gmail.com>
Thu, 1 Mar 2012 15:42:58 +0000 (13:42 -0200)
23 files changed:
contrib/tests/runtests.py
contrib/tests/test_core.py
doc/conf.py
example/app/models.py
example/app/pipeline.py
example/app/views.py
example/manage.py
setup.py
social_auth/backends/__init__.py
social_auth/backends/contrib/fitbit.py
social_auth/backends/contrib/foursquare.py
social_auth/backends/contrib/gae.py
social_auth/backends/contrib/github.py
social_auth/backends/contrib/instagram.py
social_auth/backends/facebook.py
social_auth/backends/google.py
social_auth/context_processors.py
social_auth/signals.py
social_auth/store.py
social_auth/tests/facebook.py
social_auth/tests/google.py
social_auth/utils.py
social_auth/views.py

index 8e065397a5d9af635eaa3b44b853886d80c71425..19dc42514c9da137356d6c2fea52029af36a9b29 100755 (executable)
@@ -1,8 +1,10 @@
 #!/usr/bin/env python
 
-import os, sys
+import os
+import sys
 from os.path import dirname, abspath
 
+
 os.environ['DJANGO_SETTINGS_MODULE'] = 'test_settings'
 
 parent = dirname(dirname(dirname(abspath(__file__))))
index b1fb5900a583c0be74cc43a1ab0b57bfc50a0530..9f2a60eecb13b2a9ede666708c4f4fee5a204997 100644 (file)
@@ -20,7 +20,8 @@ class BackendsTest(TestCase):
     def test_twitter_backend(self):
         # We grab the Twitter testing user details from settings file
         TEST_TWITTER_USER = getattr(settings, 'TEST_TWITTER_USER', None)
-        TEST_TWITTER_PASSWORD = getattr(settings, 'TEST_TWITTER_PASSWORD', None)
+        TEST_TWITTER_PASSWORD = getattr(settings, 'TEST_TWITTER_PASSWORD',
+                                        None)
         self.assertTrue(TEST_TWITTER_USER)
         self.assertTrue(TEST_TWITTER_PASSWORD)
 
@@ -107,7 +108,8 @@ class BackendsTest(TestCase):
 
     def test_facebook_backend(self):
         TEST_FACEBOOK_USER = getattr(settings, 'TEST_FACEBOOK_USER', None)
-        TEST_FACEBOOK_PASSWORD = getattr(settings, 'TEST_FACEBOOK_PASSWORD', None)
+        TEST_FACEBOOK_PASSWORD = getattr(settings, 'TEST_FACEBOOK_PASSWORD',
+                                         None)
         self.assertTrue(TEST_FACEBOOK_USER)
         self.assertTrue(TEST_FACEBOOK_PASSWORD)
 
@@ -135,17 +137,20 @@ class BackendsTest(TestCase):
 
     def test_linkedin_backend(self):
         TEST_LINKEDIN_USER = getattr(settings, 'TEST_LINKEDIN_USER', None)
-        TEST_LINKEDIN_PASSWORD = getattr(settings, 'TEST_LINKEDIN_PASSWORD', None)
+        TEST_LINKEDIN_PASSWORD = getattr(settings, 'TEST_LINKEDIN_PASSWORD',
+                                         None)
         self.assertTrue(TEST_LINKEDIN_USER)
         self.assertTrue(TEST_LINKEDIN_PASSWORD)
 
         self.driver.get(self.url('/login/linkedin/'))
 
         # We log in
-        username_field = self.driver.find_element_by_id('session_key-oauthAuthorizeForm')
+        username_field = self.driver.find_element_by_id(
+                                'session_key-oauthAuthorizeForm')
         username_field.send_keys(TEST_LINKEDIN_USER)
 
-        password_field = self.driver.find_element_by_id('session_password-oauthAuthorizeForm')
+        password_field = self.driver.find_element_by_id(
+                                'session_password-oauthAuthorizeForm')
         password_field.send_keys(TEST_LINKEDIN_PASSWORD)
         password_field.submit()
 
index 8e7a92c76dc1557cc63b31e272af63896c504c09..effb854dc83da7ea6175717b96c8f26130f613ea 100644 (file)
@@ -3,7 +3,8 @@
 # Django Social Auth documentation build configuration file, created by
 # sphinx-quickstart on Sun Mar 20 23:07:14 2011.
 #
-# This file is execfile()d with the current directory set to its containing dir.
+# This file is execfile()d with the current directory set to its containing
+# dir.
 #
 # Note that not all possible configuration values are present in this
 # autogenerated file.
 # All configuration values have a default; values that are commented out
 # serve to show the default.
 
-import sys, os
-
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
 # documentation root, use os.path.abspath to make it absolute, like shown here.
 #sys.path.insert(0, os.path.abspath('.'))
 
-# -- General configuration -----------------------------------------------------
+# -- General configuration ----------------------------------------------------
 
 # If your documentation needs a minimal Sphinx version, state it here.
 #needs_sphinx = '1.0'
 
-# Add any Sphinx extension module names here, as strings. They can be extensions
-# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
-extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.viewcode']
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx',
+              'sphinx.ext.todo', 'sphinx.ext.viewcode']
 
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
@@ -66,7 +66,8 @@ release = '0.6.0'
 # directories to ignore when looking for source files.
 exclude_patterns = ['_build']
 
-# The reST default role (used for this markup: `text`) to use for all documents.
+# The reST default role (used for this markup: `text`) to use for all
+# documents.
 #default_role = None
 
 # If true, '()' will be appended to :func: etc. cross-reference text.
@@ -87,7 +88,7 @@ pygments_style = 'sphinx'
 #modindex_common_prefix = []
 
 
-# -- Options for HTML output ---------------------------------------------------
+# -- Options for HTML output --------------------------------------------------
 
 # The theme to use for HTML and HTML Help pages.  See the documentation for
 # a list of builtin themes.
@@ -167,7 +168,7 @@ html_static_path = []
 htmlhelp_basename = 'DjangoSocialAuthdoc'
 
 
-# -- Options for LaTeX output --------------------------------------------------
+# -- Options for LaTeX output -------------------------------------------------
 
 # The paper size ('letter' or 'a4').
 #latex_paper_size = 'letter'
@@ -176,7 +177,8 @@ htmlhelp_basename = 'DjangoSocialAuthdoc'
 #latex_font_size = '10pt'
 
 # Grouping the document tree into LaTeX files. List of tuples
-# (source start file, target name, title, author, documentclass [howto/manual]).
+# (source start file, target name, title, author, documentclass
+# [howto/manual]).
 latex_documents = [
   ('index', 'DjangoSocialAuth.tex', u'Django Social Auth Documentation',
    u'Matías Aguirre', 'manual'),
@@ -206,7 +208,7 @@ latex_documents = [
 #latex_domain_indices = True
 
 
-# -- Options for manual page output --------------------------------------------
+# -- Options for manual page output -------------------------------------------
 
 # One entry per manual page. List of tuples
 # (source start file, name, description, authors, manual section).
index 583fa1418d24b0e454ffa157d8ff3f6c08d731d2..17765bddd1ca3c639c51ccaf92f210fcf4a56943 100644 (file)
@@ -20,6 +20,7 @@ class CustomUser(models.Model):
 from social_auth.signals import pre_update
 from social_auth.backends.facebook import FacebookBackend
 
+
 def facebook_extra_values(sender, user, response, details, **kwargs):
     return False
 
index 0d81b177829b59352189184b73320a0d7a7b27bf..b10a6659f85d87c87b522f8d4c586799b2a601e3 100644 (file)
@@ -6,9 +6,10 @@ def username(request, *args, **kwargs):
         username = kwargs['user'].username
     else:
         username = request.session.get('saved_username')
-    return { 'username': username }
+    return {'username': username}
 
 
 def redirect_to_form(*args, **kwargs):
-    if not kwargs['request'].session.get('saved_username') and kwargs.get('user') is None:
+    if not kwargs['request'].session.get('saved_username') and \
+       kwargs.get('user') is None:
         return HttpResponseRedirect('/form/')
index ef457fc8f1406464d20087cf96be18f233f9846d..3c100643a67340b3405611be7d33753afb3abdf2 100644 (file)
@@ -17,6 +17,7 @@ def home(request):
         return render_to_response('home.html', {'version': version},
                                   RequestContext(request))
 
+
 @login_required
 def done(request):
     """Login complete view, displays user data"""
@@ -26,6 +27,7 @@ def done(request):
     }
     return render_to_response('done.html', ctx, RequestContext(request))
 
+
 def error(request):
     """Error view"""
     messages = get_messages(request)
@@ -33,6 +35,7 @@ def error(request):
                                              'messages': messages},
                               RequestContext(request))
 
+
 def logout(request):
     """Logs out user"""
     auth_logout(request)
index 5e78ea979ea3846a4602f604e265fc4666beffac..0eff70a7adf02c3ae5c3a9f44836f783ff1ab6c7 100755 (executable)
@@ -1,10 +1,15 @@
 #!/usr/bin/env python
 from django.core.management import execute_manager
 try:
-    import settings # Assumed to be in the same directory.
+    import settings  # Assumed to be in the same directory.
 except ImportError:
     import sys
-    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
+    sys.stderr.write(("Error: Can't find the file 'settings.py' in the " +
+                      "directory containing %r. It appears you've "
+                      "customized things.\nYou'll have to run "
+                      "django-admin.py, passing it your settings module.\n" +
+                      "(If the file settings.py does indeed exist, it's " +
+                      "causing an ImportError somehow.)\n") % __file__)
     sys.exit(1)
 
 if __name__ == "__main__":
index 9d6f9b2f7cac7cfd99297005137e9b7f5d0874c1..8001d48a12bf4e1725c3f33a60b5953ee93df337 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -15,6 +15,7 @@ implements a common interface to define new authentication providers from
 third parties.
 """
 
+
 def long_description():
     """Return long description from README.rst if it's present
     because it doesn't get installed."""
index 79469a86c949f5e4ec58b9ad910dbf46bf7a60cd..e9c0d7ce244b9231066cb7db64a93143472e49b5 100644 (file)
@@ -170,7 +170,9 @@ class SocialAuthBackend(ModelBackend):
         raise NotImplementedError('Implement in subclass')
 
     def get_user(self, user_id):
-        """Return user with given ID from the User model used by this backend"""
+        """
+        Return user with given ID from the User model used by this backend
+        """
         try:
             return User.objects.get(pk=user_id)
         except User.DoesNotExist:
@@ -349,7 +351,7 @@ class BaseAuth(object):
         setting is per backend and defined by:
             <backend name in uppercase>_REQUEST_TOKEN_EXTRA_ARGUMENTS.
         """
-        backend_name = self.AUTH_BACKEND.name.upper().replace('-','_')
+        backend_name = self.AUTH_BACKEND.name.upper().replace('-', '_')
         return setting(backend_name + '_REQUEST_TOKEN_EXTRA_ARGUMENTS', {})
 
     def auth_extra_arguments(self):
@@ -357,7 +359,7 @@ class BaseAuth(object):
         backend and defined by:
             <backend name in uppercase>_AUTH_EXTRA_ARGUMENTS.
         """
-        backend_name = self.AUTH_BACKEND.name.upper().replace('-','_')
+        backend_name = self.AUTH_BACKEND.name.upper().replace('-', '_')
         return setting(backend_name + '_AUTH_EXTRA_ARGUMENTS', {})
 
     @property
index 031f91a50fcc24fc06a858df1ad5e3ef8b2036c0..4c7539c8210042528a165659eb890a3a7cf49745 100644 (file)
@@ -10,7 +10,7 @@ extra_data field, check OAuthBackend class for details on how to extend it.
 """
 try:
     from urlparse import parse_qs
-    parse_qs # placate pyflakes
+    parse_qs  # placate pyflakes
 except ImportError:
     # fall back for Python 2.5
     from cgi import parse_qs
index 0ba718a1c27169ed7cf71294fc886ebb8d18f8e2..369bd6ba1d55c87a0aa48ae43eab1a241fb6d706 100644 (file)
@@ -40,7 +40,7 @@ class FoursquareAuth(BaseOAuth2):
 
     def user_data(self, access_token):
         """Loads user data from service"""
-        params = {'oauth_token': access_token,}
+        params = {'oauth_token': access_token}
         url = FOURSQUARE_CHECK_AUTH + '?' + urllib.urlencode(params)
         try:
             return simplejson.load(urllib.urlopen(url))
index 72640f5996267ef0cba947e28c08725b32cded4b..38bfdb6d626fd85ea4f83756e65e94f343785eb9 100644 (file)
@@ -49,7 +49,7 @@ class GAEAuth(BaseAuth):
 
         # Setting these two are necessary for BaseAuth.authenticate to work
         kwargs.update({
-            'response' : '',
+            'response': '',
             self.AUTH_BACKEND.name: True
         })
         return authenticate(*args, **kwargs)
index c80c7c0356783d64bff0bd1e537c227efa900e1f..bd0b96049a8a4e1e07fb8424e3c1deac57544a7b 100644 (file)
@@ -43,6 +43,7 @@ class GithubBackend(OAuthBackend):
                 'email': response.get('email') or '',
                 'first_name': response.get('name')}
 
+
 class GithubAuth(BaseOAuth):
     """Github OAuth mechanism"""
     AUTH_BACKEND = GithubBackend
index e2fba7d33c97a08044b4354e3bdd82b7f5a1cc23..a40c0eeb7901c261cb5f47481e72b4afb0b5f414 100644 (file)
@@ -40,7 +40,7 @@ class InstagramAuth(BaseOAuth2):
 
     def user_data(self, access_token):
         """Loads user data from service"""
-        params = {'access_token': access_token,}
+        params = {'access_token': access_token}
         url = INSTAGRAM_CHECK_AUTH + '?' + urllib.urlencode(params)
         try:
             return simplejson.load(urllib.urlopen(url))
index 9b9e79c6783be939dc1cd638d0958acab6a44351..9943e47057f1c4f154ded2ebcec5668b0fa7a028 100644 (file)
@@ -109,9 +109,9 @@ class FacebookAuth(BaseOAuth2):
             if 'expires' in response:
                 data['expires'] = response['expires'][0]
 
-        kwargs.update({ 'auth': self,
-                        'response': data,
-                        self.AUTH_BACKEND.name: True })
+        kwargs.update({'auth': self,
+                       'response': data,
+                       self.AUTH_BACKEND.name: True})
         return authenticate(*args, **kwargs)
 
     @classmethod
index d926f5556464fe456680bae0fb576167860a257b..c596c4903d3174ec652904ba8ca9fdc32d48e248 100644 (file)
@@ -189,9 +189,8 @@ def googleapis_email(url, params):
 
     Parameters must be passed in queryset and Authorization header as described
     on Google OAuth documentation at:
-        http://groups.google.com/group/oauth/browse_thread/thread/d15add9beb418ebc
-    and:
-        http://code.google.com/apis/accounts/docs/OAuth2.html#CallingAnAPI
+    http://groups.google.com/group/oauth/browse_thread/thread/d15add9beb418ebc
+    and: http://code.google.com/apis/accounts/docs/OAuth2.html#CallingAnAPI
     """
     request = Request(url + '?' + params, headers={'Authorization': params})
     try:
index 1355be1d202214f2a8cf7cfde3fd7bcb7f84791e..1d1464ee40934ce3f2d5bf727440c4b00fe222f2 100644 (file)
@@ -22,7 +22,7 @@ def social_auth_by_type_backends(request):
     data['backends'] = group_backend_by_type(data['backends'])
     data['not_associated'] = group_backend_by_type(data['not_associated'])
     data['associated'] = group_backend_by_type(data['associated'],
-                                               key=lambda assoc: assoc.provider)
+                                              key=lambda assoc: assoc.provider)
     return {'social_auth': data}
 
 
index 7e5db38d3b00aeb8fb08220c006f690936aaa422..4ff41b8167a46b37677bad830a8ad54164619f8b 100644 (file)
@@ -19,4 +19,5 @@ pre_update = Signal(providing_args=['user', 'response', 'details'])
 
 socialauth_registered = Signal(providing_args=['user', 'response', 'details'])
 
-socialauth_not_registered = Signal(providing_args=['uid', 'response', 'details'])
+socialauth_not_registered = Signal(providing_args=['uid', 'response',
+                                                   'details'])
index a1be029011e79eebc2c2be46946f3f7e8958edb8..30aac56081d3e5be80749c589c53eb6d09aafa86 100644 (file)
@@ -50,7 +50,7 @@ class DjangoOpenIDStore(OpenIDStore):
         if expired:  # clear expired associations
             Association.objects.filter(pk__in=expired).delete()
 
-        if associations: # return most recet association
+        if associations:  # return most recet association
             associations.sort(key=lambda x: x.issued, reverse=True)
             return associations[0]
 
index 74d5b47e752b10ae9acaacbc6c1bfa4227465f51..d0a9601097611d06c209713fe9f7cd279b8628e8 100644 (file)
@@ -20,9 +20,11 @@ class FacebookTestCase(SocialAuthTestsCase):
 
 REDIRECT_RE = re.compile('window.location.replace\("(.*)"\);')
 
+
 class FacebookTestLogin(FacebookTestCase):
     def test_login_succeful(self):
-        response = self.client.get(self.reverse('socialauth_begin', 'facebook'))
+        response = self.client.get(self.reverse('socialauth_begin',
+                                                'facebook'))
         # social_auth must redirect to service page
         self.assertEqual(response.status_code, 302)
 
index 3beb5a9d7c6754823d52d890ee4d489b0de87701..e27cf88babf1808ed91ca90c31b64e2be4257111 100644 (file)
@@ -20,6 +20,7 @@ class GoogleTestCase(SocialAuthTestsCase):
 
 REDIRECT_RE = re.compile('window.location.replace\("(.*)"\);')
 
+
 class GoogleOpenIdTestLogin(GoogleTestCase):
     SERVER_NAME = 'myapp.com'
     SERVER_PORT = '8000'
@@ -32,7 +33,8 @@ class GoogleOpenIdTestLogin(GoogleTestCase):
         # Check that action and values were loaded properly
         self.assertTrue(parser.action)
         self.assertTrue(parser.values)
-        content = self.get_content(parser.action, parser.values, use_cookies=True)
+        content = self.get_content(parser.action, parser.values,
+                                   use_cookies=True)
 
         parser = FormParserByID('gaia_loginform')
         parser.feed(content)
index 747ec3b62e0971fad4a94a8641b624ba0c55f473..b7cebfa7782843c287aead3a45f7c89ef0723232 100644 (file)
@@ -30,9 +30,8 @@ def sanitize_redirect(host, redirect_to):
     """
     Given the hostname and an untrusted URL to redirect to,
     this method tests it to make sure it isn't garbage/harmful
-    and returns it, else returns None.
-
-    See http://code.djangoproject.com/browser/django/trunk/django/contrib/auth/views.py#L36
+    and returns it, else returns None, similar as how's it done
+    on django.contrib.auth.views.
 
     >>> print sanitize_redirect('myapp.com', None)
     None
@@ -111,10 +110,10 @@ if not logger:
 
 def log(level, *args, **kwargs):
     """Small wrapper around logger functions."""
-    { 'debug': logger.debug,
-      'error': logger.error,
-      'exception': logger.exception,
-      'warn': logger.warn }[level](*args, **kwargs)
+    {'debug': logger.debug,
+     'error': logger.error,
+     'exception': logger.exception,
+     'warn': logger.warn}[level](*args, **kwargs)
 
 
 def model_to_ctype(val):
index b2fdc75a5a2d779db8c8861b741656b55ca6b7ca..ad92fa26bf41e9c98a22e15ceaa68f938dafe2ed 100644 (file)
@@ -214,4 +214,5 @@ def auth_complete(request, backend, user=None, *args, **kwargs):
                                                       *args, **kwargs)
         return backend.continue_pipeline(pipeline_index=idx, *args, **kwargs)
     else:
-        return backend.auth_complete(user=user, request=request, *args, **kwargs)
+        return backend.auth_complete(user=user, request=request, *args,
+                                     **kwargs)